harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r440748 [11/25] - in /incubator/harmony/enhanced/classlib/trunk/modules: accessibility/src/main/java/javax/accessibility/ awt/ awt/make/ awt/src/main/java/common/java/awt/ awt/src/main/java/common/java/awt/datatransfer/ awt/src/main/java/co...
Date Wed, 06 Sep 2006 16:06:30 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/datatransfer/windows/WinDropTarget.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/datatransfer/windows/WinDropTarget.java?view=auto&rev=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/datatransfer/windows/WinDropTarget.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/datatransfer/windows/WinDropTarget.java
Wed Sep  6 09:06:15 2006
@@ -0,0 +1,273 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Pavel Dolgov
+ * @version $Revision$
+ */
+package org.apache.harmony.awt.datatransfer.windows;
+
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetContext;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DropTargetContextPeer;
+
+import org.apache.harmony.awt.ComponentInternals;
+import org.apache.harmony.awt.datatransfer.DataProxy;
+import org.apache.harmony.awt.datatransfer.DataSnapshot;
+import org.apache.harmony.awt.nativebridge.windows.WinDataTransfer;
+import org.apache.harmony.awt.nativebridge.windows.WindowsDefs;
+import org.apache.harmony.awt.wtk.NativeWindow;
+import org.apache.harmony.awt.wtk.NativeEventQueue.Task;
+
+/**
+ * Handles OLE drop opreration on particular heavyweight component,
+ * and dispatches DropTarget events. The drop operation runs on 
+ * DataTransferThread because DropTarget events are dispatched 
+ * synchronously. While handling the OLE callback the data transfer thread 
+ * is blocked until event dispatch thread handles the DropTargetEvent. 
+ * It is done due to synchronous nature of OLE IDropTarget callbacks. 
+ */
+public class WinDropTarget implements DropTargetContextPeer, Runnable {
+
+    private final DropTargetContext context;
+    private final long hwnd;
+    private final long dropTargetPtr;
+
+    private WinDataTransfer.IDataObject dataObject;
+    private DataProxy transferable;
+    
+    private static final int DRAG_NONE = 0;
+    private static final int DRAG_ENTER = 1;
+    private static final int DRAG_OVER = 2;
+    private static final int DRAG_DROP = 3;
+    private static final int DRAG_LEAVE = 4;
+    private int dragState;
+    private int dropAction;
+    private DropTargetEvent currentEvent;
+    private final Object dropMonitor = new Object();
+
+    private final WinDTK dtk;
+    
+    public WinDropTarget(WinDTK dtk, DropTargetContext context) {
+        this.dtk = dtk;
+        this.context = context;
+
+        ComponentInternals ci = ComponentInternals.getComponentInternals();
+        NativeWindow w = ci.getNativeWindow(context.getComponent());
+        hwnd = w.getId();
+        dropTargetPtr = registerDropTarget();
+    }
+    
+    private long registerDropTarget() {
+        Task task = new Task() {
+            public void perform() {
+                long ret = WinDataTransfer.registerDropTarget(
+                        hwnd, WinDropTarget.this);
+                returnValue = new Long(ret);
+            }
+        };
+        dtk.performTask(task);
+        return((Long)task.returnValue).longValue();
+    }
+    
+    public int getTargetActions() {
+        return context.getDropTarget().getDefaultActions();
+    }
+
+    public void setTargetActions(int actions) {
+        context.getDropTarget().setDefaultActions(actions);
+    }
+
+    public DropTarget getDropTarget() {
+        return context.getDropTarget();
+    }
+
+    public DataFlavor[] getTransferDataFlavors() {
+        return (transferable != null) ? 
+                transferable.getTransferDataFlavors() : new DataFlavor[0];
+    }
+
+    public Transferable getTransferable() throws InvalidDnDOperationException {
+        if (transferable == null) {
+            throw new InvalidDnDOperationException(
+                    "Transfer data is not available");
+        }
+        return transferable;
+    }
+
+    public boolean isTransferableJVMLocal() {
+        return false;
+    }
+
+    public void acceptDrag(int dragAction) {
+        // TODO: update dropAction
+    }
+
+    public void rejectDrag() {
+        // TODO: set dropAction to zero
+    }
+
+    public void acceptDrop(int dropAction) {
+        // TODO: update dropAction
+    }
+
+    public void rejectDrop() {
+    }
+
+    public void dropComplete(boolean success) {
+    }
+
+    /**
+     * Called from native method WinDropTarget::DragEnter()
+     * @return bit mask of DROPEFFECT_* constants according to dropAction
+     */
+    public int dragEnter(long dataObjectPtr, int x, int y, 
+                         int userAction, int sourceActions) {
+        dataObject = new WinDataTransfer.IDataObject(dataObjectPtr);
+
+        DataSnapshot snapshot = new DataSnapshot(dataObject);
+        transferable = new DataProxy(snapshot);
+        
+        DropTargetDragEvent e = new DropTargetDragEvent(
+                context, new Point(x, y), 
+                WinDragSource.getDndActions(userAction), 
+                WinDragSource.getDndActions(sourceActions));
+        
+        return dispatchEvent(e, DRAG_ENTER);
+    }
+
+    /**
+     * Called from native method WinDropTarget::DragLeave()
+     */
+    public void dragLeave() {
+        DropTargetEvent e = new DropTargetEvent(context);
+        dispatchEvent(e, DRAG_LEAVE);
+        dataObject = null;
+        transferable = null;
+    }
+
+    /**
+     * Called from native method WinDropTarget::DragOver()
+     * @return bit mask of DROPEFFECT_* constants according to dropAction
+     */
+    public int dragOver(int x, int y, int userAction, int sourceActions) {
+        DropTargetDragEvent e = new DropTargetDragEvent(
+                context, new Point(x, y), 
+                WinDragSource.getDndActions(userAction), 
+                WinDragSource.getDndActions(sourceActions));
+        
+        return dispatchEvent(e, DRAG_OVER);
+    }
+
+    /**
+     * Called from native method WinDropTarget::Drop()
+     * @return bit mask of DROPEFFECT_* constants according to dropAction
+     */
+    public int drop(long dataObjectPtr, int x, int y, 
+                    int userAction, int sourceActions) {
+        if (dataObjectPtr != dataObject.pointer) {
+            dataObject = new WinDataTransfer.IDataObject(dataObjectPtr);
+            DataSnapshot snapshot = new DataSnapshot(dataObject);
+            transferable = new DataProxy(snapshot);
+        }
+
+        DropTargetDropEvent e = new DropTargetDropEvent(
+                context, new Point(x, y), 
+                WinDragSource.getDndActions(userAction), 
+                WinDragSource.getDndActions(sourceActions));
+        
+        int ret = dispatchEvent(e, DRAG_DROP);
+        dataObject = null;
+        transferable = null;
+        return ret;
+    }
+
+    /**
+     * Call this method from {@link DropTargetContext#removeNotify()}
+     */
+    public void dispose() {
+        WinDataTransfer.revokeDropTarget(hwnd, dropTargetPtr);
+    }
+
+    /**
+     * Dispatch DropTargetEvent on event dispatch thread.
+     * {@link EventQueue#invokeLater(Runnable)} is used to invoke this method.
+     */
+    public void run() {
+        synchronized (dropMonitor) {
+            switch (dragState) {
+            case DRAG_ENTER:
+            {
+                DropTargetDragEvent e = (DropTargetDragEvent)currentEvent;
+                context.getDropTarget().dragEnter(e);
+                dropAction = e.getDropAction();
+                break;
+            }
+            case DRAG_OVER:
+            {
+                DropTargetDragEvent e = (DropTargetDragEvent)currentEvent;
+                context.getDropTarget().dragOver(e);
+                dropAction = e.getDropAction();
+                break;
+            }
+            case DRAG_DROP:
+            {
+                DropTargetDropEvent e = (DropTargetDropEvent)currentEvent;
+                context.getDropTarget().drop(e);
+                dropAction = e.getDropAction();
+                break;
+            }
+            case DRAG_LEAVE:
+            {
+                context.getDropTarget().dragExit(currentEvent);
+                dropAction = DnDConstants.ACTION_NONE;
+                break;
+            }
+            default:
+                dropAction = DnDConstants.ACTION_NONE;
+                break;
+            }
+            dragState = DRAG_NONE;
+            
+            dropMonitor.notify();
+        }
+    }
+    
+    private int dispatchEvent(DropTargetEvent e, int state) {
+        synchronized (dropMonitor) {
+            try {
+                dragState = state;
+                currentEvent = e;
+                dropAction = DnDConstants.ACTION_NONE;
+                EventQueue.invokeLater(this);
+                while (dragState != DRAG_NONE) {
+                    dropMonitor.wait();
+                }
+                return WinDragSource.getWinActions(dropAction);
+            } catch (InterruptedException ex) {
+                return WindowsDefs.DROPEFFECT_NONE;
+            }
+        }
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
Wed Sep  6 09:06:15 2006
@@ -24,7 +24,6 @@
 import java.util.*;
 
 import org.apache.harmony.awt.gl.font.FontManager;
-import org.apache.harmony.awt.gl.font.FontPeerImpl;
 import org.apache.harmony.awt.gl.font.Glyph;
 
 public class NativeFont {
@@ -34,7 +33,6 @@
      * indexing.
      */
     public static int[] famIndices = null;
-
     /**
      * List of font styles of system fonts initialized using GDI
      * corresponding to faces indexing.
@@ -82,10 +80,11 @@
      * @param winFont Windows font peer
      * @param name the name of the font
      * @param style style of the font
+     * @param size font size
      * 
      * @return native GDI font handle.
      */
-    public static native long initializeFont(WindowsFont winFont, String name, int style);
+    public static native long initializeFont(WindowsFont winFont, String name, int style,
int size);
 
     /**
      * Returns true if native GDI font can display char, false otherwise.
@@ -148,7 +147,7 @@
      * @param fontSize size of the font
      * @param usesFractionalMetrics true if results calculated using fractional metrics
      * @param fontType type of the specified font
-     * */
+     */
     public static native float[] getNativeLineMetrics(long hFont, int fontSize, boolean isAntialiased,
boolean usesFractionalMetrics, int fontType);
 
     /** 
@@ -158,7 +157,7 @@
      * @param pFnt GDI font handle
      * @param c specified char
      * @param fontSize size of the font
-     * */
+     */
     public static native float[] getGlyphInfoNative(long pFnt, char c, int fontSize);
 
     /** 
@@ -232,11 +231,36 @@
      */
     public static native int getGlyphOutline(long fnt, char uChar, long polyheaders, int
size);
 
+    /**
+     * Returns an array of extrametrics of the font:<p>
+     *  elem[0] - the average width of characters in the font (Type1 - 0.0f)<p>
+     *  elem[1] - horizontal size for subscripts (Type1 - 0.7f * fontHeight)<p> 
+     *  elem[2] - vertical size for subscripts (Type1 - 0.65f * fontHeight)<p> 
+     *  elem[3] - horizontal offset for subscripts (Type1 - 0.0f)<p>
+     *  elem[4] - vertical offset value for subscripts(Type1 - 0.15f * fontHeight)<p>
+     *  elem[5] - horizontal size for superscripts (Type1 - 0.7f * fontHeight)<p>
+     *  elem[6] - vertical size for superscripts (Type1 - 0.65f * fontHeight)<p>
+     *  elem[7] - horizontal offset for superscripts (Type1 - 0.0f)<p> 
+     *  elem[8] - vertical offset for superscripts (Type1 - 0.45f * fontHeight)<p>

+     * For TrueType fonts metrics are taken from OS2 table, for Type1 fonts
+     * metrics are calculated using coefficients (read FontExtraMetrics comments).
+     * 
+     * @param hFont GDI font handle
+     * @param fontSize font size
+     * @param fontType type of the font
+     */
+    public static native float[] getExtraMetricsNative(long hFont, int fontSize, int fontType);
+   
     /***************************************************************************
     *
     *  GDI+ text native functions
     *
     ***************************************************************************/
+
+    /**
+     * Sets antialiasing mode using GDI+ objects defined in graphics info.
+     */
+    public static native void setAntialiasing(long graphicsInfo, boolean isAntialiasing);
     
     /**
      * Draws string at the specified coordinates using GDI+ objects defined in graphics info.
@@ -244,13 +268,13 @@
      */
     public static native int gdiPlusDrawText(long graphicsInfo, String text, int length,
long font,
             float xOffset, float yOffset);
-    
+
     /** GDI+ DriverStringOptions constants */
     public static final int DriverStringOptionsCmapLookup = 1;
     public static final int DriverStringOptionsVertical = 2;
     public static final int DriverStringOptionsRealizedAdvance = 4;
     public static final int DriverStringOptionsLimitSubpixel = 8;
-    
+
     /**
      * Draws transformed char according to the matrix at the specified position.
      * @param gi GraphicsInfo pointer
@@ -353,7 +377,7 @@
              ht.put(new String("sv"), new Short((short)0x041d)); // sv-se
              ht.put(new String("th"), new Short((short)0x041e));
              ht.put(new String("tr"), new Short((short)0x041f));
-             ht.put(new String("ur"), new Short((short)0x0420)); 
+             ht.put(new String("ur"), new Short((short)0x0420));
              ht.put(new String("in"), new Short((short)0x0421)); // "id"
              ht.put(new String("uk"), new Short((short)0x0422));
              ht.put(new String("be"), new Short((short)0x0423));
@@ -365,13 +389,13 @@
              ht.put(new String("vi"), new Short((short)0x042a));
              ht.put(new String("hy"), new Short((short)0x042b));
              ht.put(new String("eu"), new Short((short)0x042d));
-             ht.put(new String("sb"), new Short((short)0x042e)); 
+             ht.put(new String("sb"), new Short((short)0x042e));
              ht.put(new String("mk"), new Short((short)0x042f));
-             ht.put(new String("sx"), new Short((short)0x0430)); 
-             ht.put(new String("ts"), new Short((short)0x0431)); 
+             ht.put(new String("sx"), new Short((short)0x0430));
+             ht.put(new String("ts"), new Short((short)0x0431));
              ht.put(new String("tn"), new Short((short)0x0432));
-             ht.put(new String("xh"), new Short((short)0x0434)); 
-             ht.put(new String("zu"), new Short((short)0x0435)); 
+             ht.put(new String("xh"), new Short((short)0x0434));
+             ht.put(new String("zu"), new Short((short)0x0435));
              ht.put(new String("af"), new Short((short)0x0436));
              ht.put(new String("fo"), new Short((short)0x0438));
              ht.put(new String("hi"), new Short((short)0x0439));
@@ -394,6 +418,7 @@
         }
         return families;
     }
+    
     /** Fills fonts and families arrays with current system font data. */
     public static void updateFontLists(){
         if (families == null){
@@ -410,7 +435,7 @@
         updateFontLists();
         return faces;
     }
-    
+
     /**
      * Returns font family name that corresposnds to the face name with 
      * specified index.
@@ -465,7 +490,7 @@
         System.arraycopy(indices, 0, famIndices, 0, fontsCount);
         System.arraycopy(fFaces, 0, faces, 0, fontsCount);
     }
-    
+
     /**
      * Returns font type (TrueType, Type1 or UndefinedType) for the specified
      * font face name and style.
@@ -495,7 +520,7 @@
 
         return FontManager.FONT_TYPE_TT;
     }
-    
+
     /** flag, returns true if native fontlib was loaded */
     private static boolean isLibLoaded = false;
 
@@ -518,4 +543,5 @@
             loadLibrary();
             updateFontLists();
     }
+
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WinFontManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WinFontManager.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WinFontManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WinFontManager.java
Wed Sep  6 09:06:15 2006
@@ -25,7 +25,6 @@
 import java.util.Properties;
 import java.util.Vector;
 
-import org.apache.harmony.awt.gl.font.CompositeFont;
 import org.apache.harmony.awt.gl.font.FontManager;
 import org.apache.harmony.awt.gl.font.FontProperty;
 
@@ -35,6 +34,16 @@
  */
 public class WinFontManager extends FontManager {
 
+    static final int DEFAULT_PITCH = 0; // GDI DEFAULT_PITCH
+    static final int FIXED_PITCH = 1;   // GDI FIXED_PITCH
+    static final int VARIABLE_PITCH = 2; // GDI VARIABLE_PITCH
+
+    static final int FF_DONTCARE = (0<<4);  // GDI FF_DONTCARE
+    static final int FF_SWISS = (2<<4);     // GDI FF_SWISS
+    static final int FF_MODERN = (3<<4);    // GDI FF_MODERN
+    static final int FF_ROMAN = (1<<4);     // GDI FF_ROMAN
+
+
     /** Available windows charset names */
     public static final String[] WINDOWS_CHARSET_NAMES = {
             "ANSI_CHARSET", "DEFAULT_CHARSET", "SYMBOL_CHARSET", "SHIFTJIS_CHARSET",
@@ -43,7 +52,7 @@
             "GREEK_CHARSET", "TURKISH_CHARSET", "VIETNAMESE_CHARSET", "THAI_CHARSET",
             "EASTEUROPE_CHARSET", "RUSSIAN_CHARSET", "MAC_CHARSET", "BALTIC_CHARSET"
     };
-    
+
     /** WinFontManager singleton instanse */
     public static final WinFontManager inst = new WinFontManager();
 
@@ -57,49 +66,6 @@
     }
 
     /**
-     * Creates and returns logical font peer. 
-     * 
-     * @param logicalName logical font family name
-     * @param font specified Font object
-     * @return In case of non-null fontproperties for the specified logical 
-     * name CompositeFont object is returned, otherwise WindowsFont object is 
-     * returned.
-     */
-    private FontPeer CreateLogicalFont(String logicalName, Font font){
-        FontProperty[] fps = getFontProperties(logicalName + "." + font.getStyle());
-        if (fps != null){
-            return new CompositeFont(font, fps, logicalName);
-        }
-        return new WindowsFont(font, true, logicalName, logicalName, 0);
-    }
-
-    public FontPeer createFont(Font font){
-        String fontName = font.getName();
-        if (isFontLogical(font)){
-            return CreateLogicalFont(fontName, font);
-        }
-
-        int fontStyle = 0;
-        String family = null;
-        String face = null;
-
-        int faceIndex = getFaceIndex(fontName);
-        // Check if name parameter is face name
-        if (faceIndex != -1){
-            fontStyle = NativeFont.getFontStyle(faceIndex);
-            family = NativeFont.getFamily(faceIndex);
-        } else {
-            return CreateLogicalFont(FontManager.LOGICAL_FONT_NAMES[3], font);  // "dialog"
-        }
-        return new WindowsFont(font, false, family, face, fontStyle);
-    }
-
-    public FontPeer createFont(FontProperty fp, int size){
-        Font propertyFont = new Font(fp.getName(), fp.getStyle(), size);
-        return createFont(propertyFont);
-    }
-
-    /**
      * Initializes fProperties array field for the current system configuration font
      * property file.
      * 
@@ -178,7 +144,7 @@
         return true;
 
     }
-
+    
     public int getFaceIndex(String faceName){
         for (int i=0; i<NativeFont.faces.length; i++ ){
             if (NativeFont.faces[i].equalsIgnoreCase(faceName))
@@ -206,5 +172,27 @@
         return allFamilies;
     }
 
+    public FontPeer createPhysicalFontPeer(String name, int style, int size) {
+        WindowsFont peer;
+        if (isFamilyExist(name)){
+            peer = new WindowsFont(name, style, size);
+            peer.setFamily(name);
+            return peer;
+        }
+        int faceIndex = getFaceIndex(name); 
+        if (faceIndex != -1){
+            style |= NativeFont.fontStyles[faceIndex];
+            name = NativeFont.getFamily(faceIndex);
+
+            peer = new WindowsFont(name, style, size);
+            return peer;
+        }
+        
+        return null;
+    }
+
+    public FontPeer createDefaultFont(int style, int size) {
+        return new WindowsFont(DEFAULT_NAME, style, size);
+    }
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
Wed Sep  6 09:06:15 2006
@@ -32,8 +32,6 @@
 import java.util.Hashtable;
 import java.util.Locale;
 
-import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
-import org.apache.harmony.awt.gl.font.FontManager;
 import org.apache.harmony.awt.gl.font.FontPeerImpl;
 import org.apache.harmony.awt.gl.font.Glyph;
 import org.apache.harmony.awt.gl.font.LineMetricsImpl;
@@ -49,35 +47,13 @@
     // Pairs of [begin, end],[..].. unicode ranges values 
     private int[] fontUnicodeRanges;
 
-    // pitch and family flag for logical font peer
-    private int fPitchAndFamily = WindowsFont.FF_DONTCARE | WindowsFont.DEFAULT_PITCH;
-    
-    // GDI pitch constants
-    private static final int DEFAULT_PITCH = 0; // GDI DEFAULT_PITCH
-    private static final int FIXED_PITCH = 1;   // GDI FIXED_PITCH
-    private static final int VARIABLE_PITCH = 2; // GDI VARIABLE_PITCH
-
-    // GDI family constants
-    private static final int FF_DONTCARE = (0<<4);  // GDI FF_DONTCARE
-    private static final int FF_SWISS = (2<<4);     // GDI FF_SWISS
-    private static final int FF_MODERN = (3<<4);    // GDI FF_MODERN
-    private static final int FF_ROMAN = (1<<4);     // GDI FF_ROMAN
-
-    public WindowsFont(Font font, boolean isLogical, String familyName, String faceName,
int fontStyle) {
-
-        this.name = font.getName();
-        this.size = font.getSize();
-        this.style = font.getStyle();
-
-        this.fontFamilyName = familyName;
-        this.faceName = faceName;
-
-        if (isLogical){
-            this.setFPitchAndFamily(FontManager.getLogicalIndex(this.name.toLowerCase()));
-            this.psName  = familyName;  // logical name
-        }
-
-        pFont = NativeFont.initializeFont(this, this.fontFamilyName, this.style | fontStyle);
+    public WindowsFont(String fontName, int fontStyle, int fontSize) {
+        this.size = fontSize;
+        this.style = fontStyle;
+        this.name = fontName;
+        this.fontFamilyName = name;
+        
+        pFont = NativeFont.initializeFont(this, fontName, fontStyle, fontSize);
 
         initWindowsFont();
 
@@ -107,7 +83,7 @@
         }
 //      this.defaultChar = NativeFont.getDefaultCharNative(pFont);
 
-        addGlyphs((char) 0x20, (char) 0x7E);
+//        addGlyphs((char) 0x20, (char) 0x7E);
     }
 
     /**
@@ -242,15 +218,7 @@
         return result;
 
     }
-    /**
-     * Dispose native font handle.
-     */
-    public void freeResource() {
-        if (pFont != 0) {
-            NativeFont.pFontFree(pFont);
-        }
-    }
-    
+
     /**
      * Returns string image, that can be blitted onto a BufferedImageGraphics2D.
      * @param str the specified string
@@ -329,7 +297,7 @@
 
        return this.getFontName();
     }
-
+    
     /**
      * Returns a clone of LineMetrics object that contains metrics of this 
      * WindowsFont.
@@ -373,45 +341,15 @@
      * if this WindowsFont object was created from stream.
      */
     public void dispose(){
-        NativeFont.pFontFree(this.pFont);
-        if (this.isCreatedFromStream()) {
-            NativeFont.RemoveFontResource(this.getTempFontFileName());
-        }
-    }
+        if (pFont != 0){
+            NativeFont.pFontFree(pFont);
+            pFont = 0;
 
-    /**
-     * Set pitch and family flag in case of predefined logical names as.
-     * If the list fonts in the font.propery file that corresponds to the
-     * logical name is absent or there is no such fonts in the 
-     * GraphicsEnvironment, flag fPitchAndFamily set to the corresponding 
-     * to the logical name value. This value is used in GDI native font 
-     * handle creation. 
-     */
-    private void setFPitchAndFamily(int logFontNameIndex){
-        switch (logFontNameIndex){
-            case DIALOG:
-            case SANSSERIF:
-                this.fPitchAndFamily = WindowsFont.FF_SWISS | WindowsFont.VARIABLE_PITCH;
-                break;
-            case DIALOGINPUT:
-            case MONOSPACED:
-                this.fPitchAndFamily = WindowsFont.FF_MODERN | WindowsFont.FIXED_PITCH;
-                break;
-            case SERIF:
-                this.fPitchAndFamily = WindowsFont.FF_ROMAN | WindowsFont.VARIABLE_PITCH;
-                break;
-            default:
-                this.fPitchAndFamily = WindowsFont.FF_DONTCARE | WindowsFont.DEFAULT_PITCH;
+            if (isCreatedFromStream()) {
+                NativeFont.RemoveFontResource(getTempFontFileName());
+            }
+            
         }
-
-    }
-
-    /**
-     * Returns pitch and family flag of this WindowsFont 
-     * for the logical font creation by means of GDI purpose.
-     */
-    public int getFPitchAndFamily(){
-        return this.fPitchAndFamily;
     }
 
     /**
@@ -420,7 +358,7 @@
     public String getPSName(){
         if (psName == null){
             // TODO: implement method
-            psName = this.faceName;
+            psName = getFontName();
         }
         return psName;
     }
@@ -444,12 +382,28 @@
     public String getFontName() {
         if (faceName == null){
             if (this.fontType == FontManager.FONT_TYPE_T1)
-                faceName = fontFamilyName;
+                faceName = getFamily();
             else
-                faceName = NativeFont.getFontNameNative(this.getFontHandle());
+                faceName = NativeFont.getFontNameNative(this.pFont);
         }
 
         return faceName;
     }
+    
+    /**
+     * Returns initiated FontExtraMetrics instance of this WindowsFont.
+     */
+    public FontExtraMetrics getExtraMetrics(){
+        if (extraMetrix == null){
+
+            //!! for Type1 fonts 'x' char width used as average char width
+            float[] metrics = NativeFont.getExtraMetricsNative(this.getFontHandle(), this.size,
this.fontType);
+            if (fontType == FontManager.FONT_TYPE_T1){
+                metrics[0] = charWidth('x');
+            }
+            extraMetrix = new FontExtraMetrics(metrics);
+        }
+        return extraMetrix;
+    }   
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java
Wed Sep  6 09:06:15 2006
@@ -104,16 +104,19 @@
                 float alpha = ac.getAlpha();
                 if(srcSurf instanceof ImageSurface){
                     if(bgcolor == null || srcSurf.getTransparency() == Transparency.OPAQUE){
-                        bltImage(srcX, srcY, srcSurfStruct, ((ImageSurface)srcSurf).getData(),
+                        bltImage(srcX, srcY, srcSurfStruct, srcSurf.getData(),
                                 dstX, dstY, dstSurfStruct,
                                 width, height, compType, alpha,
-                                matrix, clipRects, numVertex);
+                                matrix, clipRects, numVertex, 
+                                srcSurf.invalidated());
                     }else{
-                        bltBGImage(srcX, srcY, srcSurfStruct, ((ImageSurface)srcSurf).getData(),
+                        bltBGImage(srcX, srcY, srcSurfStruct, srcSurf.getData(),
                                 dstX, dstY, dstSurfStruct,
                                 width, height, bgcolor.getRGB(),
-                                compType, alpha, matrix, clipRects, numVertex);
+                                compType, alpha, matrix, clipRects, 
+                                numVertex, srcSurf.invalidated());
                     }
+                    srcSurf.validate();
                 }else{
                     bltBitmap(srcX, srcY, srcSurfStruct,
                             dstX, dstY, dstSurfStruct,
@@ -123,10 +126,11 @@
             }else if(comp instanceof XORComposite){
                 XORComposite xcomp = (XORComposite) comp;
                 if(srcSurf instanceof ImageSurface){
-                    xorImage(srcX, srcY, srcSurfStruct, ((ImageSurface)srcSurf).getData(),
+                    xorImage(srcX, srcY, srcSurfStruct, srcSurf.getData(),
                             dstX, dstY, dstSurfStruct,
                             width, height, xcomp.getXORColor().getRGB(),
-                            matrix, clipRects, numVertex);
+                            matrix, clipRects, numVertex, srcSurf.invalidated());
+                    srcSurf.validate();
                 }else{
                     xorBitmap(srcX, srcY, srcSurfStruct,
                             dstX, dstY, dstSurfStruct,
@@ -134,7 +138,8 @@
                             matrix, clipRects, numVertex);
                 }
             }else{
-                throw new IllegalArgumentException("Unknown Composite type - " + comp.getClass());
+                throw new IllegalArgumentException("Unknown Composite type - " + 
+                        comp.getClass());
             }
         }else{
             BufferedImage bi;
@@ -165,13 +170,13 @@
             Object srcData, int dstX, int dstY, long dstSurfDataPtr,
             int width, int height, int bgcolor,
             int compType, float alpha, double matrix[],
-            int clip[], int numVertex);
+            int clip[], int numVertex, boolean invalidated);
 
     private native void bltImage(int srcX, int srcY, long srsSurfDataPtr,
             Object srcData, int dstX, int dstY, long dstSurfDataPtr,
             int width, int height, int compType,
             float alpha, double matrix[],
-            int clip[], int numVertex);
+            int clip[], int numVertex, boolean invalidated);
 
     private native void bltBitmap(int srcX, int srcY, long srsSurfDataPtr,
             int dstX, int dstY, long dstSurfDataPtr,
@@ -182,7 +187,7 @@
     private native void xorImage(int srcX, int srcY, long srsSurfDataPtr,
             Object srcData, int dstX, int dstY, long dstSurfDataPtr,
             int width, int height, int xorcolor, double matrix[],
-            int clip[], int numVertex);
+            int clip[], int numVertex, boolean invalidated);
 
     private native void xorBitmap(int srcX, int srcY, long srsSurfDataPtr,
             int dstX, int dstY, long dstSurfDataPtr,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIPTextRenderer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIPTextRenderer.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIPTextRenderer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIPTextRenderer.java
Wed Sep  6 09:06:15 2006
@@ -246,7 +246,7 @@
         double positions[] = new double[size*2];
         char chars[] = new char[size];
         int count = 0;
-        WindowsFont physFont = (WindowsFont)wcf.physicalFonts[charFontIndex];
+        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
         
         long font = physFont.getFontHandle();
 
@@ -295,7 +295,7 @@
 
                     count = 0;
                     font = gl.getPFont();
-                    physFont = (WindowsFont)wcf.physicalFonts[charFontIndex];
+                    physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
                 }else {
                     chars[count] = c;
                     int ind = count * 2;
@@ -432,7 +432,7 @@
                     status);
         }
     }
-    
+
     /**
      * Method for fast drawing strings at the desired coordinates with Graphics 
      * or Font object has transforms.
@@ -525,7 +525,7 @@
         int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
         int fontIndex = charFontIndex;
 
-        WindowsFont physFont = (WindowsFont)wcf.physicalFonts[charFontIndex];
+        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
         
         long font = physFont.getFontHandle();
         float yPos = 0;    // Y position to draw (y - font.ascent)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java
Wed Sep  6 09:06:15 2006
@@ -36,10 +36,6 @@
 import org.apache.harmony.awt.nativebridge.windows.Win32;
 
 /**
- * @author Ilya S. Okomin
- * @version $Revision$
- *
- * Created on 28.02.2005
  *
  * TextRenderer that works by means of GDI calls.
  */
@@ -267,7 +263,7 @@
         int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
         int fontIndex = charFontIndex;
 
-        WindowsFont physFont = (WindowsFont)wcf.physicalFonts[charFontIndex];
+        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
         long font = physFont.getFontHandle();
 
         win32.SelectObject(hdc, font);
@@ -300,7 +296,7 @@
                 count = 1;
                 start = i;
 
-                physFont = (WindowsFont)wcf.physicalFonts[charFontIndex];
+                physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
                 font = physFont.getFontHandle();
                 win32.SelectObject(hdc, font);
                 yOffset = y - physFont.getAscent();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java
Wed Sep  6 09:06:15 2006
@@ -27,15 +27,18 @@
 import java.awt.GraphicsConfiguration;
 import java.awt.Paint;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import java.awt.Shape;
 import java.awt.Stroke;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.PathIterator;
 import java.awt.geom.Point2D;
+import java.util.Map;
 
 import org.apache.harmony.awt.gl.CommonGraphics2D;
 import org.apache.harmony.awt.gl.MultiRectArea;
+import org.apache.harmony.awt.gl.font.NativeFont;
 import org.apache.harmony.awt.wtk.NativeWindow;
 
 
@@ -132,6 +135,15 @@
         setTransform(getTransform());
     }
 
+    public void addRenderingHints(Map hints) {
+        super.addRenderingHints(hints);
+        Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+        if (value == RenderingHints.VALUE_ANTIALIAS_ON) 
+            NativeFont.setAntialiasing(gi,true);
+        else
+            NativeFont.setAntialiasing(gi,false);
+    }
+    
     public void copyArea(int x, int y, int width, int height, int dx, int dy) {
         copyArea(gi, x, y, width, height, dx, dy);
     }
@@ -497,6 +509,24 @@
 
     // Fill native primitives
     private native void fillRect(long gi, int x, int y, int width, int height);
+
+    public void setRenderingHint(RenderingHints.Key key, Object value) {
+        super.setRenderingHint(key,value);
+        Object val = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+        if (val == RenderingHints.VALUE_ANTIALIAS_ON) 
+            NativeFont.setAntialiasing(gi,true);
+        else
+            NativeFont.setAntialiasing(gi,false);
+    }
+
+    public void setRenderingHints(Map hints) {
+        super.setRenderingHints(hints);
+        Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+        if (value == RenderingHints.VALUE_ANTIALIAS_ON) 
+            NativeFont.setAntialiasing(gi,true);
+        else
+            NativeFont.setAntialiasing(gi,false);
+    }
 
 
     // Set native clip

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/nativebridge/windows/Callback.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/nativebridge/windows/Callback.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/nativebridge/windows/Callback.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/nativebridge/windows/Callback.java
Wed Sep  6 09:06:15 2006
@@ -26,12 +26,18 @@
     }
 
     private static long callbackWNDPROC = 0;
+    private static long callbackOFNHOOKPROC = 0;
+    private static long callbackDataTransferProc = 0;
 
     private static Handler handler;
+    private static Handler handlerOFN;
+    private static Handler handlerDataTransfer;
 
     static {
         System.loadLibrary("Win32Wrapper");
         callbackWNDPROC = initCallBackWNDPROC();
+        callbackOFNHOOKPROC = initCallBackOFNHOOKPROC();
+        callbackDataTransferProc = initCallBackDataTransferProc();
     }
 
     public static long registerCallback(Handler h) {
@@ -41,13 +47,34 @@
         handler = h;
         return callbackWNDPROC;
     }
+    
+    public static long registerCallbackOFN(Handler h) {        
+        handlerOFN = h;
+        return callbackOFNHOOKPROC;
+    }
+
+    public static long registerCallbackDataTransfer(Handler h) {        
+        handlerDataTransfer = h;
+        return callbackDataTransferProc;
+    }
 
     private static native long initCallBackWNDPROC();
+    private static native long initCallBackOFNHOOKPROC();
+    private static native long initCallBackDataTransferProc();
 
     /**
      * Calls registred java method. Called from JNI code.
      */
     static long runCallbackWNDPROC(long p1, int p2, long p3, long p4) {
         return (handler != null) ? handler.windowProc(p1, p2, p3, p4) : 0;
+    }
+    
+    static long runCallbackOFNHOOKPROC(long p1, int p2, long p3, long p4) {
+        return (handlerOFN != null) ? handlerOFN.windowProc(p1, p2, p3, p4) : 0;
+    }
+
+    static long runCallbackDataTransferProc(long p1, int p2, long p3, long p4) {
+        return (handlerDataTransfer != null) ? 
+                handlerDataTransfer.windowProc(p1, p2, p3, p4) : 0;
     }
 }



Mime
View raw message