[Gd-chatter] r11495 - branches/opendylan-melange/gtk-duim

hannes at gwydiondylan.org hannes at gwydiondylan.org
Wed Nov 21 23:52:05 CET 2007


Author: hannes
Date: Wed Nov 21 23:52:04 2007
New Revision: 11495

Modified:
   branches/opendylan-melange/gtk-duim/gtk-draw.dylan
   branches/opendylan-melange/gtk-duim/gtk-fonts.dylan
   branches/opendylan-melange/gtk-duim/gtk-mirror.dylan
Log:
Job: fd
use GtkFixed instead of our own Fixed, this enables
 events and we can draw lines and text
implement bold and italic fonts



Modified: branches/opendylan-melange/gtk-duim/gtk-draw.dylan
==============================================================================
--- branches/opendylan-melange/gtk-duim/gtk-draw.dylan	(original)
+++ branches/opendylan-melange/gtk-duim/gtk-draw.dylan	Wed Nov 21 23:52:04 2007
@@ -463,6 +463,7 @@
 //  let renderer = gdk-pango-renderer-get-default(screen);
 //  gdk-pango-renderer-set-gc(renderer, gcontext);
   let context = gdk-pango-context-get-for-screen(screen);
+  let (_font, _width, _height, ascent) = gtk-font-metrics(font, context);
   let layout = pango-layout-new(context);
   pango-layout-set-font-description(layout, font.%font-description);
   let transform = medium-device-transform(medium);
@@ -483,8 +484,7 @@
           pango-layout-set-text(layout, substring, e - s);
 //          pango-layout-context-changed(layout);
 //          pango-renderer-draw-layout(renderer, layout, tab-origin + x, y);
-          gdk-draw-line(drawable, gcontext, 0, 0, 100, 100);
-          gdk-draw-layout(drawable, gcontext, tab-origin + x, y + 50, layout);
+          gdk-draw-layout(drawable, gcontext, tab-origin + x, y - ascent, layout);
 	  if (e = _end)
 	    break()
 	  else
@@ -504,7 +504,7 @@
       pango-layout-set-text(layout, substring, -1);
       //pango-layout-context-changed(layout);
       //pango-renderer-draw-layout(renderer, layout, x, y);
-      gdk-draw-layout(drawable, gcontext, x, y, layout);
+      gdk-draw-layout(drawable, gcontext, x, y - ascent, layout);
     end
   end
 end method draw-text;

Modified: branches/opendylan-melange/gtk-duim/gtk-fonts.dylan
==============================================================================
--- branches/opendylan-melange/gtk-duim/gtk-fonts.dylan	(original)
+++ branches/opendylan-melange/gtk-duim/gtk-fonts.dylan	Wed Nov 21 23:52:04 2007
@@ -101,10 +101,19 @@
                else
                  second(find-pair($gtk-logical-sizes, text-style-size(text-style)))
                end;
+    let attributes = "";
+    if (text-style-weight(text-style) == #"bold")
+      attributes := concatenate(attributes, "bold ");
+    end;
+    if (text-style-slant(text-style) == #"italic")
+      attributes := concatenate(attributes, "italic ");
+    end;
     let font-name
-      = format-to-string("%s %d",
+      = format-to-string("%s %s%d",
                          second(find-pair($gtk-font-families, text-style-family(text-style))),
+                         attributes,
                          size);
+    duim-debug-message("do-text-style-mapping: %s", font-name);
     let font-description = pango-font-description-from-string(font-name); 
     let font = make(<gtk-font>, name: font-name, description: font-description);
     table[text-style] := font;
@@ -189,16 +198,23 @@
 end;
 
 define sealed method gtk-font-metrics
-    (font :: <gtk-font>, _port :: <gtk-port>)
+    (font :: <gtk-font>, pango-context :: <PangoContext>)
  => (font :: <gtk-font>,
      width :: <integer>, height :: <integer>, ascent :: <integer>, descent :: <integer>)
-  let pango-context = gtk-get-pango-context-from-port(_port);
   let metrics = pango-context-get-metrics(pango-context, font.%font-description, pango-language-get-default());
   values(font,
          round/(pango-font-metrics-get-approximate-char-width(metrics), $PANGO-SCALE),
          round/(pango-font-metrics-get-ascent(metrics) + pango-font-metrics-get-descent(metrics), $PANGO-SCALE),
          round/(pango-font-metrics-get-ascent(metrics), $PANGO-SCALE),
          round/(pango-font-metrics-get-descent(metrics), $PANGO-SCALE));
+end;
+
+define sealed method gtk-font-metrics
+    (font :: <gtk-font>, _port :: <gtk-port>)
+ => (font :: <gtk-font>,
+     width :: <integer>, height :: <integer>, ascent :: <integer>, descent :: <integer>)
+  let pango-context = gtk-get-pango-context-from-port(_port);
+  gtk-font-metrics(font, pango-context);
 end method gtk-font-metrics;
 
 

Modified: branches/opendylan-melange/gtk-duim/gtk-mirror.dylan
==============================================================================
--- branches/opendylan-melange/gtk-duim/gtk-mirror.dylan	(original)
+++ branches/opendylan-melange/gtk-duim/gtk-mirror.dylan	Wed Nov 21 23:52:04 2007
@@ -21,6 +21,11 @@
   #t
 end method port-handles-repaint?;
 
+define method port-handles-repaint?
+    (_port :: <gtk-port>, sheet :: <sheet-with-repainting-mixin>)
+ => (true? :: <boolean>)
+  #f
+end method port-handles-repaint?;
 
 /// GTK mirrors
 
@@ -306,7 +311,7 @@
 define method do-make-gtk-mirror 
     (sheet :: <mirrored-sheet-mixin>)
 => (mirror :: <widget-mirror>)
-  let widget = with-gdk-lock fixed-new() end;
+  let widget = with-gdk-lock gtk-fixed-new() end;
   //---*** We really want to switch this off entirely...
   //gtk-container-set-resize-mode(widget, $GTK-RESIZE-QUEUE);
   make(<fixed-container-mirror>,
@@ -319,7 +324,7 @@
   => (mirror :: <widget-mirror>)
   let widget = with-gdk-lock gtk-drawing-area-new() end;
 //  gtk-drawing-area-size(widget, 200, 200);
-//  gtk-widget-set-size-request(widget, 200, 200);
+  gtk-widget-set-size-request(widget, 200, 200);
   make(<drawing-area-mirror>,
        widget: widget,
        sheet:  sheet);
@@ -454,6 +459,17 @@
   end
 end method move-mirror;
 
+define method move-mirror
+    (parent :: <fixed-container-mirror>, child :: <scrolled-mirror>,
+     x :: <integer>, y :: <integer>)
+ => ()
+  with-gdk-lock
+    gtk-fixed-move(mirror-widget(parent),
+                   scrolled-window(child),
+                   x, y)
+  end
+end method move-mirror;
+
 define method size-mirror
     (parent :: <fixed-container-mirror>, child :: <widget-mirror>,
      width :: <integer>, height :: <integer>)
@@ -478,7 +494,10 @@
 
 define method set-widget-size (mirror :: <widget-mirror>, widget :: <GtkWidget>, width :: <integer>, height :: <integer>)
   gtk-debug("set-mirror-size for %= to %=x%=", widget, width, height);
-  let (left, top) = box-position(mirror.%region);
+  with-gdk-lock
+    gtk-widget-set-size-request(widget, width, height);
+  end;
+/*let (left, top) = box-position(mirror.%region);
   with-stack-structure (allocation :: <GtkAllocation>)
     allocation.GdkRectangle-x      := left;
     allocation.GdkRectangle-y      := top;
@@ -487,7 +506,7 @@
     with-gdk-lock
       gtk-widget-size-allocate(widget, allocation)
     end
-  end;
+  end;*/
 end method;
 
 define method set-mirror-size
@@ -496,7 +515,7 @@
 //  gtk-drawing-area-size(mirror-widget(mirror), width, height);
   gtk-debug("set-mirror-size for %= to %=x%= (ignored)", mirror-widget(mirror), width, height);
   with-gdk-lock
-//    gtk-widget-set-size-request(mirror-widget(mirror), width, height);
+    gtk-widget-set-size-request(mirror-widget(mirror), width, height);
   end
 end method set-mirror-size;
 



More information about the chatter mailing list