ecere/gfx/GDI: Fix for computing text extents with Display::FontExtent() on alpha...
authorJerome St-Louis <jerome@ecere.com>
Sat, 4 Feb 2012 17:32:16 +0000 (00:32 +0700)
committerJerome St-Louis <jerome@ecere.com>
Sat, 4 Feb 2012 17:32:16 +0000 (00:32 +0700)
ecere/src/gfx/Display.ec
extras/gui/IconBag.ec

index 560f4ed..32e3608 100644 (file)
@@ -1,5 +1,9 @@
 namespace gfx;
 
+#if (defined(ECERE_VANILLA) || defined(ECERE_ONEDRIVER)) && defined(__WIN32__)
+#define ECERE_NOTRUETYPE
+#endif
+
 import "System"
 
 import "Color"
@@ -12,6 +16,11 @@ import "BitmapResource"
 
 import "LFBDisplayDriver"
 
+// TOFIX: Temporary until we pass Display instead of DisplaySystem to FontExtent
+#if defined(__WIN32__) && !defined(ECERE_NOTRUETYPE)
+import "GDIDisplayDriver"
+#endif
+
 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
 import "Camera"
 import "Plane"
@@ -495,7 +504,23 @@ public:
 
    void FontExtent(Font font, char * text, int len, int * width, int * height)
    {
-      DisplaySystem::FontExtent(this ? displaySystem : null, font, text, len, width, height);
+      // Fix for OnLoadGraphics time alpha blended window text extent on GDI
+#if defined(__WIN32__) && !defined(ECERE_NOTRUETYPE)
+      if(this && alphaBlend && pixelFormat == pixelFormat888 && 
+         displaySystem.driver == class(GDIDisplayDriver))
+      {
+         Surface s = GetSurface(0,0,null);
+         if(s)
+         {
+            s.font = font;
+            s.TextExtent(text, len, width, height);
+            delete s;
+         }
+      }
+      else
+#endif
+         // TODO: Should really pass display here...
+         DisplaySystem::FontExtent(this ? displaySystem : null, font, text, len, width, height);
    }
 
    void SetPalette(ColorAlpha * palette, bool colorMatch)
index 83f31ad..7c9f6d3 100644 (file)
@@ -21,7 +21,7 @@ public:
    {
       set
       {
-         iconNames.Copy(value);
+         iconNames.Copy((void *)value);  // TOFIX: Warning without the void * cast
       }
    }