jdk/src/windows/native/sun/windows/awt_Font.h
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
     2
 * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef AWT_FONT_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define AWT_FONT_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awt.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "awt_Object.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "java_awt_Font.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "sun_awt_windows_WFontMetrics.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "sun_awt_FontDescriptor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "sun_awt_PlatformFont.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * AwtFont utilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
extern jboolean IsMultiFont(JNIEnv *env, jobject obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define GET_PLATFORMFONT(font)\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    (env->CallObjectMethod(env, font, AwtFont::peerMID))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * AwtFont class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
class AwtFont : public AwtObject {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /* int[] width field for sun.awt.windows.WFontDescriptor */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    static jfieldID widthsID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /* int fields for sun.awt.windows.WFontDescriptor */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static jfieldID ascentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    static jfieldID descentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    static jfieldID leadingID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    static jfieldID heightID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    static jfieldID maxAscentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    static jfieldID maxDescentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static jfieldID maxHeightID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    static jfieldID maxAdvanceID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /* sun.awt.FontDescriptor fontDescriptor field of sun.awt.CharsetString */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    static jfieldID fontDescriptorID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /* java.lang.String charsetString field of sun.awt.CharsetString */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    static jfieldID charsetStringID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /* java.lang.String nativeName field of sun.awt.FontDescriptor*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    static jfieldID nativeNameID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /* boolean useUnicode field of sun.awt.FontDescriptor*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    static jfieldID useUnicodeID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /* long field pData of java.awt.Font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    static jfieldID pDataID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /* java.awt.peer.FontPeer field peer of java.awt.Font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    static jmethodID peerMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /* java.lang.String name field of java.awt.Font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    static jfieldID nameID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /* int size field of java.awt.Font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    static jfieldID sizeID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /* int style field of java.awt.Font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    static jfieldID styleID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /* java.awt.Font peer field of java.awt.FontMetrics */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    static jfieldID fontID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /* sun.awt.FontConfiguration fontConfig field of sun.awt.PlatformFont */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    static jfieldID fontConfigID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /* FontDescriptor[] componentFonts field of sun.awt.PlatformFont */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    static jfieldID componentFontsID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /* String textComponentFontName field of sun.awt.windows.WFontPeer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    static jfieldID textComponentFontNameID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /* String fontName field of sun.awt.windows.WDefaultFontCharset fields */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    static jfieldID fontNameID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    static jmethodID makeConvertedMultiFontStringMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /* java.awt.Font methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    static jmethodID getFontMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /* java.awt.FontMetrics methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    static jmethodID getHeightMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * The argument is used to determine how many handles of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Windows font the instance has.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    AwtFont(int num, JNIEnv *env, jobject javaFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    ~AwtFont();    /* Releases all resources */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    virtual void Dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Access methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    INLINE int GetHFontNum()     { return m_hFontNum; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    INLINE HFONT GetHFont(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        DASSERT(m_hFont[i] != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return m_hFont[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /* Used to keep English version unchanged as much as possiple. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    INLINE HFONT GetHFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        DASSERT(m_hFont[0] != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return m_hFont[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    INLINE int GetInputHFontIndex() { return m_textInput; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    INLINE void SetAscent(int ascent) { m_ascent = ascent; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    INLINE int GetAscent()           { return m_ascent; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    INLINE int GetOverhang()         { return m_overhang; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Font methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Returns the AwtFont object associated with the pFontJavaObject.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * If none exists, create one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    static AwtFont* GetFont(JNIEnv *env, jobject font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                            jint angle=0, jfloat awScale=1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Creates the specified font.  name names the font.  style is a bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * vector that describes the style of the font.  height is the point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * size of the font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    static AwtFont* Create(JNIEnv *env, jobject font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                           jint angle = 0, jfloat awScale=1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    static HFONT CreateHFont(WCHAR* name, int style, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                             int angle = 0, float awScale=1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    static void Cleanup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * FontMetrics methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Loads the metrics of the associated font.  See Font.GetFont for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * purpose of pWS.  (Also, client should provide Font java object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * instead of getting it from the FontMetrics instance variable.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    static void LoadMetrics(JNIEnv *env, jobject fontMetrics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /* Returns the AwtFont associated with this metrics. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    static AwtFont* GetFontFromMetrics(JNIEnv *env, jobject fontMetrics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Sets the ascent of the font.  This member should be called if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * font->m_nAscent < 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    static void SetupAscent(AwtFont* font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Determines the average dimension of the character in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * specified font 'font' and multiplies it by the specified number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * of rows and columns.  'font' can be a temporary object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    static SIZE TextSize(AwtFont* font, int columns, int rows);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * If 'font' is NULL, the SYSTEM_FONT is used to compute the size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * 'font' can be a temporary object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    static int getFontDescriptorNumber(JNIEnv *env, jobject font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                       jobject fontDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * 'font' is of type java.awt.Font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    static SIZE DrawStringSize_sub(jstring str, HDC hDC, jobject font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                   long x, long y, BOOL draw,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                   UINT codePage = 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    INLINE static SIZE drawMFStringSize(HDC hDC, jobject font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                                        jstring str, long x, long y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                        UINT codePage = 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return DrawStringSize_sub(str, hDC, font, x, y, TRUE , codePage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    INLINE static SIZE getMFStringSize(HDC hDC, jobject font, jstring str,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                       UINT codePage = 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return DrawStringSize_sub(str, hDC, font, 0, 0, FALSE, codePage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    INLINE static long getMFStringWidth(HDC hDC, jobject font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                            jstring str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return getMFStringSize(hDC, font, str).cx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    INLINE static void drawMFString(HDC hDC, jobject font, jstring str,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                    long x, long y, UINT codePage = 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        DrawStringSize_sub(str, hDC, font, x, y, TRUE, codePage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    INLINE static jobjectArray GetComponentFonts(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                                                     jobject font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
      jobject platformFont = env->CallObjectMethod(font, AwtFont::peerMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      jobjectArray result =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
          (jobjectArray)(env->GetObjectField(platformFont,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                                             AwtFont::componentFontsID));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
      env->DeleteLocalRef(platformFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
      return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
   /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    * Variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
private:
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   245
    /* The array of associated font handles */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    HFONT* m_hFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /* The number of handles. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    int    m_hFontNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /* The index of the handle used to be set to AwtTextComponent. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    int    m_textInput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /* The ascent of this font. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    int m_ascent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /* The overhang, or amount added to a string's width, of this font. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    int m_overhang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /* angle of text rotation in 10'ths of a degree*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    int textAngle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /* average width scale factor to be applied */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    float awScale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
class AwtFontCache {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
private:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    class Item {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        Item(const WCHAR* s, HFONT f, Item* n = NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        ~Item();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        WCHAR*      name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        HFONT       font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        Item*       next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        DWORD       refCount;   /*  The same HFONT can be associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                                    multiple Java objects.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    AwtFontCache() { m_head = NULL; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    void    Add(WCHAR* name, HFONT font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    HFONT   Lookup(WCHAR* name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    BOOL    Search(HFONT font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    void    Remove(HFONT font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    void    Clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    void    IncRefCount(HFONT hFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    LONG    IncRefCount(Item* item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    LONG    DecRefCount(Item* item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    Item* m_head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
#define GET_FONT(target, OBJ) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    ((jobject)env->CallObjectMethod(target, AwtComponent::getFontMID))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
#endif /* AWT_FONT_H */