Reverse viewing

Koos Vriezen koos.vriezen at xs4all.nl
Fri Apr 4 22:54:48 BST 2003


Hi,

Attached a 10 minutes, not fully functional, hack for reverse viewing in
khtml. It's probably useless, but otoh it's very small and adds a
funny viewing option.
(see for a screenshot http://www.xs4all.nl/~jjvrieze/khtml_reverse.png)

Koos
-------------- next part --------------
Index: khtml_ext.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_ext.cpp,v
retrieving revision 1.64
diff -u -3 -p -r1.64 khtml_ext.cpp
--- khtml_ext.cpp	26 Feb 2003 21:33:42 -0000	1.64
+++ khtml_ext.cpp	4 Apr 2003 21:39:16 -0000
@@ -273,6 +273,7 @@ public:
   KAction *m_paStopAnimations;
   KAction *m_paCopyImageLocation;
   KAction *m_paViewImage;
+  KToggleAction *m_paViewReverse;
   KAction *m_paReloadFrame;
   KAction *m_paViewFrameSource;
   KAction *m_paViewFrameInfo;
@@ -320,6 +321,8 @@ KHTMLPopupGUIClient::KHTMLPopupGUIClient
 
   d->m_paStopAnimations = new KAction( i18n( "Stop Animations" ), 0, this, SLOT( slotStopAnimations() ),
                                        actionCollection(), "stopanimations" );
+  d->m_paViewReverse = new KToggleAction( i18n( "View Reverse" ), 0, this, SLOT( slotViewReverse() ),
+                                        actionCollection(), "viewreverse" );
 
   DOM::Element e;
   e = khtml->nodeUnderMouse();
@@ -423,6 +426,11 @@ void KHTMLPopupGUIClient::slotCopyImageL
 void KHTMLPopupGUIClient::slotViewImage()
 {
   d->m_khtml->browserExtension()->createNewWindow(d->m_imageURL.url());
+}
+
+void KHTMLPopupGUIClient::slotViewReverse()
+{
+  d->m_khtml->view()->setReverseView( d->m_paViewReverse->isChecked() );
 }
 
 void KHTMLPopupGUIClient::slotReloadFrame()
Index: khtml_ext.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_ext.h,v
retrieving revision 1.21
diff -u -3 -p -r1.21 khtml_ext.h
--- khtml_ext.h	28 Nov 2002 06:49:20 -0000	1.21
+++ khtml_ext.h	4 Apr 2003 21:39:17 -0000
@@ -98,6 +98,7 @@ private slots:
   void slotStopAnimations();
   void slotCopyImageLocation();
   void slotViewImage();
+  void slotViewReverse();
   void slotReloadFrame();
 private:
   class KHTMLPopupGUIClientPrivate;
Index: khtml_popupmenu.rc
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_popupmenu.rc,v
retrieving revision 1.21
diff -u -3 -p -r1.21 khtml_popupmenu.rc
--- khtml_popupmenu.rc	28 Nov 2002 06:49:20 -0000	1.21
+++ khtml_popupmenu.rc	4 Apr 2003 21:39:17 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"><kpartgui name="khtmlpart_popupmenu" version="8">
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"><kpartgui name="khtmlpart_popupmenu" version="9">
 <Menu name="popupmenu">
  <Action name="reloadframe" group="reload" />
  <Action name="printFrame" group="print" />
@@ -13,6 +13,7 @@
  <Action name="stopanimations" />
  <Action name="copyimagelocation" />
  <Action name="viewimage" />
+ <Action name="viewreverse" />
  <Separator weakSeparator="1" />
  <Action name="viewDocumentSource" />
  <Action name="viewFrameSource" />
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.515
diff -u -3 -p -r1.515 khtmlview.cpp
--- khtmlview.cpp	2 Apr 2003 22:22:10 -0000	1.515
+++ khtmlview.cpp	4 Apr 2003 21:39:18 -0000
@@ -103,6 +103,7 @@ public:
         prevScrollbarVisible = true;
 	tooltip = 0;
         possibleTripleClick = false;
+        m_reverseview = false;
     }
     ~KHTMLViewPrivate()
     {
@@ -226,6 +227,7 @@ public:
     bool dirtyLayout;
     bool repaintLayout;
     bool m_dialogsAllowed;
+    bool m_reverseview;
     QRect updateRect;
     KHTMLToolTip *tooltip;
     QPtrDict<QWidget> visibleWidgets;
@@ -377,6 +379,8 @@ void KHTMLView::drawContents( QPainter *
         p->fillRect(ex, ey, ew, eh, palette().active().brush(QColorGroup::Base));
         return;
     }
+    if (d->m_reverseview)
+        p->setRasterOp(Qt::NotCopyROP);
     if (eh > PAINT_BUFFER_HEIGHT && ew <= 10) {
         if ( d->vertPaintBuffer->height() < visibleHeight() )
             d->vertPaintBuffer->resize(10, visibleHeight());
@@ -411,6 +415,8 @@ void KHTMLView::drawContents( QPainter *
             py += PAINT_BUFFER_HEIGHT;
         }
     }
+    if (d->m_reverseview)
+        p->setRasterOp(Qt::CopyROP);
 
     khtml::DrawContentsEvent event( p, ex, ey, ew, eh );
     QApplication::sendEvent( m_part, &event );
@@ -1747,4 +1753,9 @@ void KHTMLView::complete()
         killTimer(d->repaintTimerId);
         d->repaintTimerId = startTimer( 20 );
     }
+}
+
+void KHTMLView::setReverseView(bool reverse) {
+    d->m_reverseview = reverse;
+    static_cast<khtml::RenderRoot *>(m_part->xmlDocImpl()->renderer())->repaint();
 }
Index: khtmlview.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v
retrieving revision 1.177
diff -u -3 -p -r1.177 khtmlview.h
--- khtmlview.h	2 Apr 2003 22:22:10 -0000	1.177
+++ khtmlview.h	4 Apr 2003 21:39:18 -0000
@@ -154,6 +154,8 @@ public:
      */
     void layout();
 
+    void setReverseView(bool reverse=true);
+
 signals:
     void cleared();
     void zoomView( int );


More information about the kfm-devel mailing list