changeset 1932:22d9dd1fb523

merge
author Jorge Arellano Cid <jcid@dillo.org>
date Wed, 09 Mar 2011 17:07:35 -0300
parents 36cec2fa951a (current diff) 370e97c9f39b (diff)
children cedef3974c12
files
diffstat 8 files changed, 134 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkcomplexbutton.cc	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkcomplexbutton.cc	Wed Mar 09 17:07:35 2011 -0300
@@ -173,7 +173,6 @@
   down_box(FL_NO_BOX);
   value_ = oldval = 0;
   shortcut_ = 0;
-  set_flag(SHORTCUT_LABEL);
 }
 
 ComplexButton::~ComplexButton() {
--- a/dw/fltkplatform.cc	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkplatform.cc	Wed Mar 09 17:07:35 2011 -0300
@@ -191,26 +191,6 @@
 FltkTooltip::FltkTooltip (const char *text) : Tooltip(text)
 {
    shown = false;
-
-   if (!text || !strpbrk(text, "&@")) {
-      escaped_str = NULL;
-   } else {
-      /*
-       * WORKAROUND: ::fltk::Tooltip::tooltip_timeout() makes instance_
-       * if necessary, and immediately uses it. This means that we can't
-       * get our hands on it to set RAW_LABEL until after it has been shown
-       * once. So let's escape the special characters ourselves.
-       */
-      const char *src = text;
-      char *dest = escaped_str = (char *) malloc(strlen(text) * 2 + 1);
-
-      while (*src) {
-         if (*src == '&' || *src == '@')
-            *dest++ = *src;
-         *dest++ = *src++;
-      }
-      *dest = '\0';
-   }
 }
 
 FltkTooltip::~FltkTooltip ()
@@ -221,8 +201,6 @@
    if (shown)
       Fl_Tooltip::exit();
 #endif
-   if (escaped_str)
-      free(escaped_str);
 }
 
 FltkTooltip *FltkTooltip::create (const char *text)
@@ -235,7 +213,7 @@
    Fl_Widget *widget = Fl::belowmouse();
 
    Fl_Tooltip::enter_area(widget, widget->x(), widget->y(), widget->w(),
-                          widget->h(), escaped_str ? escaped_str : str);
+                          widget->h(), str);
    shown = true;
 }
 
--- a/dw/fltkplatform.hh	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkplatform.hh	Wed Mar 09 17:07:35 2011 -0300
@@ -60,7 +60,6 @@
    FltkTooltip (const char *text);
    ~FltkTooltip ();
    bool shown;
-   char *escaped_str; /* fltk WORKAROUND */
 public:
    static FltkTooltip *create(const char *text);
    void onEnter();
--- a/dw/fltkui.cc	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkui.cc	Wed Mar 09 17:07:35 2011 -0300
@@ -244,7 +244,6 @@
    Fl_Button *button =
         new Fl_Button (allocation->x, allocation->y, allocation->width,
                        allocation->ascent + allocation->descent, label);
-// button->clear_flag (SHORTCUT_LABEL);
    button->callback (widgetCallback, this);
    button->when (FL_WHEN_RELEASE);
    return button;
@@ -736,7 +735,6 @@
    Fl_Check_Button *cb =
       new Fl_Check_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-// cb->clear_flag (SHORTCUT_LABEL);
    return cb;
 }
 
@@ -848,7 +846,6 @@
    Fl_Button *button =
       new Fl_Round_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-// button->clear_flag (SHORTCUT_LABEL);
    button->when (FL_WHEN_CHANGED);
    button->callback (widgetCallback, this);
    button->type (FL_TOGGLE_BUTTON);
@@ -1061,7 +1058,6 @@
    tree->showroot(0);
    tree->connectorstyle(FL_TREE_CONNECTOR_NONE);
    tree->marginleft(-14);
-// tree->clear_flag (SHORTCUT_LABEL);
    tree->callback(widgetCallback,this);
    tree->when(FL_WHEN_CHANGED);
 
--- a/dw/fltkviewbase.cc	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkviewbase.cc	Wed Mar 09 17:07:35 2011 -0300
@@ -35,7 +35,32 @@
 namespace dw {
 namespace fltk {
 
-Fl_Image *FltkViewBase::backBuffer;
+FltkViewBase::BackBuffer::BackBuffer ()
+{
+   w = 0;
+   h = 0;
+   created = false;
+}
+
+FltkViewBase::BackBuffer::~BackBuffer ()
+{
+   if (created)
+      fl_delete_offscreen (offscreen);
+}
+
+void FltkViewBase::BackBuffer::setSize (int w, int h)
+{
+   if (!created || w > this->w || h > this->h) {
+      this->w = w;
+      this->h = h;
+      if (created)
+         fl_delete_offscreen (offscreen);
+      offscreen = fl_create_offscreen (w, h);
+      created = true;
+   }
+}
+
+FltkViewBase::BackBuffer *FltkViewBase::backBuffer;
 bool FltkViewBase::backBufferInUse;
 
 FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label):
@@ -46,13 +71,10 @@
    canvasHeight = 1;
    bgColor = FL_WHITE;
    mouse_x = mouse_y = 0;
-#if 0
-PORT1.3
    exposeArea = NULL;
    if (backBuffer == NULL) {
-      backBuffer = new Fl_Image ();
+      backBuffer = new BackBuffer ();
    }
-#endif
 }
 
 FltkViewBase::~FltkViewBase ()
@@ -62,10 +84,7 @@
 
 void FltkViewBase::setBufferedDrawing (bool b) {
    if (b && backBuffer == NULL) {
-#if 0
-PORT1.3 
-      backBuffer = new Fl_Image ();
-#endif
+      backBuffer = new BackBuffer ();
    } else if (!b && backBuffer != NULL) {
       delete backBuffer;
       backBuffer = NULL;
@@ -112,67 +131,6 @@
 void FltkViewBase::draw (const core::Rectangle *rect,
                          DrawType type)
 {
-#if 0
-PORT1.3
-   int offsetX = 0, offsetY = 0;
-
-   /* fltk-clipping does not use widget coordinates */
-   transform (offsetX, offsetY);
-
-   ::fltk::Rectangle viewRect (
-      translateCanvasXToViewX (rect->x) + offsetX,
-      translateCanvasYToViewY (rect->y) + offsetY,
-      rect->width, rect->height);
-
-   ::fltk::intersect_with_clip (viewRect);
-
-   viewRect.x (viewRect.x () - offsetX);
-   viewRect.y (viewRect.y () - offsetY);A
-
-   if (! viewRect.empty ()) {
-      dw::core::Rectangle r (
-         translateViewXToCanvasX (viewRect.x ()),
-         translateViewYToCanvasY (viewRect.y ()),
-         viewRect.w (),
-         viewRect.h ());
-
-      exposeArea = &viewRect;
-
-      if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) {
-         backBufferInUse = true;
-         {
-            GSave gsave;
-
-            backBuffer->setsize (viewRect.w (), viewRect.h ());
-            backBuffer->make_current ();
-            translate (-viewRect.x (), -viewRect.y ());
-
-            setcolor (bgColor);
-            fillrect (viewRect);
-            theLayout->expose (this, &r);
-         }
-
-         backBuffer->draw (Rectangle (0, 0, viewRect.w (), viewRect.h ()),
-            viewRect);
-
-         backBufferInUse = false;
-      } else if (type == DRAW_BUFFERED || type == DRAW_CLIPPED) {
-         // if type == DRAW_BUFFERED but we do not have backBuffer available
-         // we fall back to clipped drawing
-         fl_push_clip (viewRect);
-         setcolor (bgColor);
-         fillrect (viewRect);
-         theLayout->expose (this, &r);
-         fl_pop_clip ();
-      } else {
-         setcolor (bgColor);
-         fillrect (viewRect);
-         theLayout->expose (this, &r);
-      }
-
-      exposeArea = NULL;
-   }
-#endif
    int X, Y, W, H;
    
    fl_clip_box(translateCanvasXToViewX (rect->x),
@@ -181,12 +139,41 @@
                rect->height,
                X, Y, W, H);
 
-   fl_color(bgColor);
-   fl_rectf(X, Y, W, H);
-
    core::Rectangle r (translateViewXToCanvasX (X),
                       translateViewYToCanvasY (Y), W, H);
-   theLayout->expose (this, &r);
+
+   if (r.isEmpty ())
+      return;
+
+   exposeArea = &r;
+
+   if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) {
+      backBufferInUse = true;
+      backBuffer->setSize (X + W, Y + H); // would be nicer to use (W, H)...
+      fl_begin_offscreen (backBuffer->offscreen);
+      fl_push_matrix ();
+      fl_color (bgColor);
+      fl_rectf (X, Y, W, H);
+      theLayout->expose (this, &r);
+      fl_pop_matrix ();
+      fl_end_offscreen ();
+      fl_copy_offscreen (X, Y, W, H, backBuffer->offscreen, X, Y);
+      backBufferInUse = false;
+   } else if (type == DRAW_BUFFERED || type == DRAW_CLIPPED) {
+      // if type == DRAW_BUFFERED but we do not have backBuffer available
+      // we fall back to clipped drawing
+      fl_push_clip (X, Y, W, H);
+      fl_color (bgColor);
+      fl_rectf (X, Y, W, H);
+      theLayout->expose (this, &r);
+      fl_pop_clip ();
+   } else {
+      fl_color (bgColor);
+      fl_rectf (X, Y, W, H);
+      theLayout->expose (this, &r);
+   }
+
+   exposeArea = NULL;
 }
 
 void FltkViewBase::drawChildWidgets () {
@@ -387,6 +374,11 @@
                              int x1, int y1, int x2, int y2)
 {
    fl_color(((FltkColor*)color)->colors[shading]);
+   // we clip with a large border (5000px), as clipping causes artefacts
+   // with non-solid line styles.
+   // However it's still better than no clipping at all.
+   clipPoint (&x1, &y1, 5000);
+   clipPoint (&x2, &y2, 5000);
    fl_line (translateCanvasXToViewX (x1),
             translateCanvasYToViewY (y1),
             translateCanvasXToViewX (x2),
@@ -441,19 +433,21 @@
       height = -height;
    }
 
-   int x1 = translateCanvasXToViewX (X);
-   int y1 = translateCanvasYToViewY (Y);
-   int x2 = translateCanvasXToViewX (X + width);
-   int y2 = translateCanvasYToViewY (Y + height);
+   int x1 = X;
+   int y1 = Y;
+   int x2 = X + width;
+   int y2 = Y + height;
 
-#if 0
-PORT1.3
    // We only support rectangles with line width 1px, so we clip with
    // a rectangle 1px wider and higher than what we actually expose.
    // This is only really necessary for non-filled rectangles.
    clipPoint (&x1, &y1, 1);
    clipPoint (&x2, &y2, 1);
-#endif
+
+   x1 = translateCanvasXToViewX (x1);
+   y1 = translateCanvasYToViewY (y1);
+   x2 = translateCanvasXToViewX (x2);
+   y2 = translateCanvasYToViewY (y2);
 
    if (filled)
       fl_rectf (x1, y1, x2 - x1, y2 - y1);
--- a/dw/fltkviewbase.hh	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkviewbase.hh	Wed Mar 09 17:07:35 2011 -0300
@@ -5,7 +5,7 @@
 #include <sys/time.h>     // for time_t in FreeBSD
 
 #include <FL/Fl_Group.H>
-#include <FL/Fl_Image.H>
+#include <FL/x.H>
 #include <FL/Fl_Scrollbar.H>
 
 #include "fltkcore.hh"
@@ -16,30 +16,42 @@
 class FltkViewBase: public FltkView, public Fl_Group
 {
 private:
+   class BackBuffer {
+      private:
+         int w;
+         int h;
+         bool created;
+
+      public:
+         Fl_Offscreen offscreen;
+      
+         BackBuffer ();
+         ~BackBuffer ();
+         void setSize(int w, int h);
+   };
+
    typedef enum { DRAW_PLAIN, DRAW_CLIPPED, DRAW_BUFFERED } DrawType;
 
    int bgColor;
    core::Region drawRegion;
-   //::fltk::Rectangle *exposeArea;
-   static Fl_Image *backBuffer;
+   core::Rectangle *exposeArea;
+   static BackBuffer *backBuffer;
    static bool backBufferInUse;
 
    void draw (const core::Rectangle *rect, DrawType type);
    void drawChildWidgets ();
-#if 0
    inline void clipPoint (int *x, int *y, int border) {
       if (exposeArea) {
-         if (*x < exposeArea->x () - border)
-            *x = exposeArea->x () - border;
-         if (*x > exposeArea->r () + border)
-            *x = exposeArea->r () + border;
-         if (*y < exposeArea->y () - border)
-            *y = exposeArea->y () - border;
-         if (*y > exposeArea->b () + border)
-            *y = exposeArea->b () + border;
+         if (*x < exposeArea->x - border)
+            *x = exposeArea->x - border;
+         if (*x > exposeArea->x + exposeArea->width + border)
+            *x = exposeArea->x + exposeArea->width + border;
+         if (*y < exposeArea->y - border)
+            *y = exposeArea->y - border;
+         if (*y > exposeArea->y + exposeArea->height + border)
+            *y = exposeArea->y + exposeArea->height + border;
       }
    }
-#endif
 protected:
    core::Layout *theLayout;
    int canvasWidth, canvasHeight;
--- a/dw/fltkviewport.cc	Wed Mar 09 14:26:19 2011 -0300
+++ b/dw/fltkviewport.cc	Wed Mar 09 17:07:35 2011 -0300
@@ -375,9 +375,9 @@
 void FltkViewport::scroll (core::ScrollCommand cmd)
 {
    if (cmd == core::SCREEN_UP_CMD) {
-      scroll (0, -h ());
+      scroll (0, -h () + vscrollbar->linesize ());
    } else if (cmd == core::SCREEN_DOWN_CMD) {
-      scroll (0, h ());
+      scroll (0, h () - vscrollbar->linesize ());
    } else if (cmd == core::LINE_UP_CMD) {
       scroll (0, (int) -vscrollbar->linesize ());
    } else if (cmd == core::LINE_DOWN_CMD) {
--- a/src/dillo.cc	Wed Mar 09 14:26:19 2011 -0300
+++ b/src/dillo.cc	Wed Mar 09 17:07:35 2011 -0300
@@ -24,8 +24,9 @@
 #include <signal.h>
 #include <locale.h>
 
+#include <FL/Fl.H>
 #include <FL/Fl_Window.H>
-#include <FL/Fl.H>
+#include <FL/fl_draw.H>
 
 #include "msg.h"
 #include "paths.hh"
@@ -167,6 +168,25 @@
    }
    return opt_id;
 }
+
+static void custLabelDraw(const Fl_Label* o, int X, int Y, int W, int H,
+                          Fl_Align align)
+{
+   const int interpret_symbols = 0;
+
+   fl_font(o->font, o->size);
+   fl_color((Fl_Color)o->color);
+   fl_draw(o->value, X, Y, W, H, align, o->image, interpret_symbols);
+}
+
+static void custLabelMeasure(const Fl_Label* o, int& W, int& H)
+{
+   const int interpret_symbols = 0;
+
+   fl_font(o->font, o->size);
+   fl_measure(o->value, W, H, interpret_symbols);
+}
+
 #if 0
 PORT1.3
 /*
@@ -318,6 +338,10 @@
 
    // Sets WM_CLASS hint on X11
    Fl_Window::default_xclass("dillo");
+
+   // Disable '@' interpretation in labels
+   Fl::set_labeltype(FL_NORMAL_LABEL, custLabelDraw, custLabelMeasure);
+
 #if 0
 PORT1.3
    checkPreferredFonts();
@@ -331,6 +355,12 @@
    // Create a new UI/bw pair
    BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, xid, NULL);
 
+   /* We need this so that fl_text_extents() in dw/fltkplatform.cc can
+    * work when FLTK is configured without XFT and Dillo is opening
+    * immediately-available URLs from the cmdline (e.g. about:splash).
+    */
+   ((Fl_Widget *)bw->ui)->window()->make_current();
+
    /* Proxy authentication */
    if (prefs.http_proxyuser && !a_Http_proxy_auth()) {
       const char *passwd = a_UIcmd_get_passwd(prefs.http_proxyuser);