[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    Re: Kword gui code done for PageUp - PageDown
From:       John Califf <jcaliff () usit ! net>
Date:       2000-09-18 6:26:34
[Download RAW message or body]

Werner Trobin wrote:
> 
> John Califf wrote:
> >
> 
> ::snip::
> 
> > I need help on how to submit the patch (being new at Kde development).
> > Currently I have an unaltered copy of the two files from the snapshots
> > (exactly the same as what's on cvs as they haven't been changed) and my
> > changed versions.  All I know to do is attach a text file with the
> > diffs:
> >
> >              diff -c original myversion > xxx.diff.
> >
> > Someone who has cvs permission (Werner?) will have to review my changes
> > and then commit them or explain what format to submit my changes in for
> > review.
> 
> Hehe - you forgot to attach it ;)
> Please use diff -u (unified diff, easier to read)
> 
> Apart from that I have to tell you that I'm not very familiar with
> the KWord interals and that Thomas Zander of Shaheed Haque are the
> people to review the patch ;)
> 
> --
> Werner Trobin - trobin@kde.org


Funny, I didn't say that I had attached anything yet.  Ok, I did the
diff -u using two directories original and changed containing the
kword_page files I chaged.  So, I will now attempt to attach it using
Netscape so those familiar with KWord internals can apply the changes. 
Note - this is NOT using cvs but the original files are from cvs, so if
there is some other method I should use please explain explicitly with a
full command to use.   It's very straightforward though and should just
be a matter of cut an paste.  Please feel free to edit what I send but
please test your changes, if any, also.  Thanks for supplying the names
of those currently working on KWord, Thomas and Shaheed.
["kword_page.diff" (text/plain)]

diff -u original/kword_page.cc changed/kword_page.cc
--- original/kword_page.cc	Mon Sep 18 02:07:28 2000
+++ changed/kword_page.cc	Mon Sep 18 02:06:37 2000
@@ -2437,6 +2437,105 @@
     return TRUE;
 }
 
+
+/*=============================
+  kNext - Next key handler - same as PageDown. Move cursor down one 
+  visible document area height and adjust page view accordingly
+			  ===================================*/
+
+bool KWPage::kPrior( QKeyEvent *e, int, int, KWParag *parag, KWTextFrameSet *fs )
+{
+	// can't go to a negative pixel value - set new Y offset to
+	// zero if visible height of viewport is greater than offset
+	// from start of fc + top border height
+	
+	unsigned int newY = fc->getPTY();
+	if(newY <= ptTopBorder())  return FALSE;
+	
+	if(fc->getPTY() >= visibleHeight())
+	{ 
+		newY = fc->getPTY() - visibleHeight();
+		if(newY <= ptTopBorder()) newY = ptTopBorder(); 
+	}	
+	else
+		newY = ptTopBorder();	
+	   
+    if ( !doc->has_selection() && e->state() & ShiftButton )
+        startKeySelection();
+    else
+        *oldFc = *fc;
+
+    bool gotoPrevTableCell = FALSE;
+    if ( fs->getGroupManager() && !parag->getPrev() ) 
+	{
+        if ( fc->isCursorInFirstLine() )
+            gotoPrevTableCell = TRUE;
+    }
+    
+	// move cursor up 1 visible height, keeping current x position
+	fc->cursorGotoPixelLine(fc->getPTPos(), newY);
+	
+    gui->getView()->setFormat( *( ( KWFormat* )fc ) );
+    gui->getView()->setFlow( fc->getParag()->getParagLayout()->getFlow() );
+    gui->getView()->setLineSpacing( \
fc->getParag()->getParagLayout()->getLineSpacing().pt() ); +    \
gui->getView()->setParagBorders( fc->getParag()->getParagLayout()->getLeftBorder(), + \
fc->getParag()->getParagLayout()->getRightBorder(), +                                 \
fc->getParag()->getParagLayout()->getTopBorder(), +                                   \
fc->getParag()->getParagLayout()->getBottomBorder() ); +
+    if ( continueSelection || e->state() & ShiftButton ) 
+	{
+        continueKeySelection();
+        return FALSE;
+    } 
+	else if ( gotoPrevTableCell )
+        cursorGotoPrevTableCell();
+
+    return TRUE;
+}
+
+/*=============================
+  kNext - Next key handler - same as PageDown
+  move cursor down one visible document area height
+  and adjust page view accordingly
+===================================*/
+
+bool KWPage::kNext( QKeyEvent *e, int, int, KWParag *parag, KWTextFrameSet *fs )
+{
+	if ( !doc->has_selection() && e->state() & ShiftButton )
+        startKeySelection();
+    else
+        *oldFc = *fc;
+
+    bool gotoNextTableCell = FALSE;
+    if ( fs->getGroupManager() && !parag->getNext() ) {
+        if ( fc->isCursorInLastLine() )
+            gotoNextTableCell = TRUE;
+    }
+	
+	// move cursor down 1 visible height, keeping current x position
+	fc->cursorGotoPixelLine(fc->getPTPos(), fc->getPTY() + visibleHeight());
+
+    gui->getView()->setFormat( *( ( KWFormat* )fc ) );
+    gui->getView()->setFlow( fc->getParag()->getParagLayout()->getFlow() );
+    gui->getView()->setLineSpacing( \
fc->getParag()->getParagLayout()->getLineSpacing().pt() ); +    \
gui->getView()->setParagBorders( fc->getParag()->getParagLayout()->getLeftBorder(), + \
fc->getParag()->getParagLayout()->getRightBorder(), +                                 \
fc->getParag()->getParagLayout()->getTopBorder(), +                                   \
fc->getParag()->getParagLayout()->getBottomBorder() ); +
+    if ( continueSelection || e->state() & ShiftButton ) 
+	{
+        continueKeySelection();
+        return FALSE;
+    } 
+	else if ( gotoNextTableCell )
+        cursorGotoNextTableCell();
+
+    return TRUE;
+}
+
+
 /*================================================================*/
 bool KWPage::kReturn( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
KWTextFrameSet *frameSet )  {
@@ -2797,6 +2896,21 @@
             STOP;
 
     switch( e->key() ) {
+	// -jwc- Key_Prior and Key_Next are same as Key_PageUp and Key_PageDown
+	// These should exhibit expected behavior - scroll viewport 1 screen
+	// with - necessary for expected navigation I would think! 
+    case Key_Prior:
+	{
+        if ( !kPrior( e, oldPage, oldFrame, oldParag, frameSet ) )
+            STOP;
+        break;
+	}	
+    case Key_Next:
+	{
+        if ( !kNext( e, oldPage, oldFrame, oldParag, frameSet ) )
+		  STOP;
+        break;
+	}	
     case Key_Home:
         if ( !kHome( e, oldPage, oldFrame, oldParag, frameSet ) )
             STOP;
diff -u original/kword_page.h changed/kword_page.h
--- original/kword_page.h	Mon Sep 18 02:07:23 2000
+++ changed/kword_page.h	Mon Sep 18 02:06:32 2000
@@ -360,6 +360,11 @@
     bool kLeft( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
                KWTextFrameSet *frameSet );
     bool kUp( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
                KWTextFrameSet *frameSet );
     bool kDown( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
KWTextFrameSet *frameSet ); +
+	/* -jwc- PageUp and PageDown event handlers */
+    bool kPrior( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
KWTextFrameSet *frameSet ); +    bool kNext( QKeyEvent *e, int oldPage, int oldFrame, \
KWParag *oldParag, KWTextFrameSet *frameSet ); +	
     bool kReturn( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
                KWTextFrameSet *frameSet );
     bool kDelete( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
                KWTextFrameSet *frameSet );
     bool kBackspace( QKeyEvent *e, int oldPage, int oldFrame, KWParag *oldParag, \
KWTextFrameSet *frameSet );



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic