summaryrefslogtreecommitdiff
path: root/vcl/aqua
diff options
context:
space:
mode:
authorBabak Mahbod <bmahbod@openoffice.org>2001-03-26 20:53:17 +0000
committerBabak Mahbod <bmahbod@openoffice.org>2001-03-26 20:53:17 +0000
commite572dde0790d443c09054975b64ca16e291fc4bb (patch)
tree78debad271b2b95fb05fa1f96d3a0777ee97a73f /vcl/aqua
parent5f397a92986f77393f5c8c9020360fd87249acf1 (diff)
Source code changes and clean up for utility methods and APIs
Diffstat (limited to 'vcl/aqua')
-rw-r--r--vcl/aqua/inc/salatsuifontutils.hxx105
-rwxr-xr-xvcl/aqua/inc/salconst.h54
-rw-r--r--vcl/aqua/inc/salfontutils.hxx38
-rwxr-xr-xvcl/aqua/inc/salmathutils.hxx6
-rw-r--r--vcl/aqua/source/gdi/salatsuifontutils.cxx576
5 files changed, 86 insertions, 693 deletions
diff --git a/vcl/aqua/inc/salatsuifontutils.hxx b/vcl/aqua/inc/salatsuifontutils.hxx
index 25c529f60eb6..7fe59c05dbcc 100644
--- a/vcl/aqua/inc/salatsuifontutils.hxx
+++ b/vcl/aqua/inc/salatsuifontutils.hxx
@@ -2,8 +2,8 @@
*
* $RCSfile: salatsuifontutils.hxx,v $
*
- * $Revision: 1.2 $
- * last change: $Author: pluby $ $Date: 2001-03-13 09:44:40 $
+ * $Revision: 1.3 $
+ * last change: $Author: bmahbod $ $Date: 2001-03-26 21:53:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,54 +86,35 @@
#endif
#include <premac.h>
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
+ #include <Carbon/Carbon.h>
+ #include <ApplicationServices/ApplicationServices.h>
#include <postmac.h>
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
// =======================================================================
// =======================================================================
-const short kMacOSCharSize = sizeof(char);
-
-// -----------------------------------------------------------------------
-
-const short kFontFamilyNameLength = 32;
-const short kFontStyleNameLength = 32;
-
-const long kFontFamilyNameMemSize = kFontFamilyNameLength * kMacOSCharSize;
-
-const long kFontStyleNameMemSize = kFontStyleNameLength * kMacOSCharSize;
-
-
-// -----------------------------------------------------------------------
-
-// To have fonts show up in a different style than the actual menu fonts
-// one must change this value.
-
-const short kATSUIFontInstanceMenuItemStyle = 0;
+static const short kMacOSCharSize = sizeof(char);
+ static const short kFontFamilyNameLength = 32; static const short kFontStyleNameLength = 32;
+ static const long kFontFamilyNameMemSize = kFontFamilyNameLength * kMacOSCharSize;
+static const long kFontStyleNameMemSize = kFontStyleNameLength * kMacOSCharSize;
// -----------------------------------------------------------------------
// For simplicity, only this number of font axis variations are considered.
-const short kATSUIMaxVariations = 32;
+static const short kATSUIMaxVariations = 32;
// -----------------------------------------------------------------------
// To filter out invisible fonts
-const char kInvalidFontNamePrefixPeriodSign = '.';
-const char kInvalidFontNamePrefixPercentSign = '%';
-
-// -----------------------------------------------------------------------
-
-const SInt16 kMenuBufferMaxLength = 255;
-const MacOSStringPtr kMenuItemGenericName = "\pGeneric text";
+static const char kInvalidFontNamePrefixPeriodSign = '.';
+static const char kInvalidFontNamePrefixPercentSign = '%';
// =======================================================================
@@ -149,53 +130,7 @@ enum
// =======================================================================
-typedef short ATSUIInstanceIndex;
-
-// -----------------------------------------------------------------------
-
-struct FontNameEncodingRecord
-{
- FontPlatformCode mnFontPlatformCode;
- FontScriptCode mnFontScriptCode;
- FontLanguageCode mnFontLanguageCode;
- ItemCount mnFontItemCount;
-};
-
-typedef struct FontNameEncodingRecord FontNameEncodingRecord;
-typedef FontNameEncodingRecord *FontNameEncodingPtr;
-typedef FontNameEncodingPtr *FontNameEncodingMatrix;
-
-// -----------------------------------------------------------------------
-
-struct FontNamesRecord
-{
- ATSUFontID mnFontID;
- FontNameEncodingRecord maFontFamilyNameEncoding;
- FontNameEncodingRecord maFontStyleNameEncoding;
- ATSUIInstanceIndex mnFontInstanceIndex;
- ByteOffset mnFontStyleByteOffset;
- char mpFontName[ 1 ];
-};
-
-typedef struct FontNamesRecord FontNamesRecord;
-typedef FontNamesRecord *FontNamesPtr;
-typedef FontNamesPtr *FontNamesMatrix;
-
-// -----------------------------------------------------------------------
-
-struct FontMenuItemRecord
-{
- short mnFontMenuID;
- short mnFontItemNum;
- ATSUFontID mnFontID;
- ATSUIInstanceIndex mnFontInstanceIndex;
-};
-
-typedef struct FontMenuItemRecord FontMenuItemRecord;
-typedef FontMenuItemRecord *FontMenuItemPtr;
-typedef FontMenuItemPtr *FontMenuItemsHandle;
-
-// =======================================================================
+typedef short ATSUIInstanceIndex; // ----------------------------------------------------------------------- struct FontNameEncodingRecord { FontPlatformCode mnFontPlatformCode; FontScriptCode mnFontScriptCode; FontLanguageCode mnFontLanguageCode; ItemCount mnFontItemCount; }; typedef struct FontNameEncodingRecord FontNameEncodingRecord; typedef FontNameEncodingRecord *FontNameEncodingPtr; typedef FontNameEncodingPtr *FontNameEncodingMatrix; // ----------------------------------------------------------------------- struct FontNamesRecord { ATSUFontID mnFontID; FontNameEncodingRecord maFontFamilyNameEncoding; FontNameEncodingRecord maFontStyleNameEncoding; ATSUIInstanceIndex mnFontInstanceIndex; ByteOffset mnFontStyleByteOffset; char mpFontName[ 1 ]; }; typedef struct FontNamesRecord FontNamesRecord; typedef FontNamesRecord *FontNamesPtr; typedef FontNamesPtr *FontNamesMatrix; // =======================================================================
// =======================================================================
@@ -225,18 +160,10 @@ typedef FontMenuItemPtr *FontMenuItemsHandle;
// =======================================================================
-OSStatus ATSUIAppendFontMenu( MenuHandle hFontMenu,
- short nHierarchiaFontMenuID,
- short *rSubmenuCount,
- void **hFontMenuLookupCookie
- );
-
OSStatus ATSUIDisposeFontNames( const ItemCount nFontListLength,
FontNamesMatrix hFontNames
);
-OSStatus ATSUIDisposeFontMenuLookupCookie( void *pMenuLookupCookie );
-
OSStatus ATSUIFindBestFontName( ATSUFontID nFontID,
FontNameCode nFontNameCode,
FontPlatformCode *rFontPlatformCode,
@@ -254,12 +181,6 @@ OSStatus ATSUIFONDtoFontID( short nFONDNumber,
StyleParameter *rIntrinsicStyleParameter
);
-ATSUFontID ATSUIGetFontForFontMenuItem( short nMenuID,
- short nMenuItemNum,
- void *pMenuLookupCookie,
- ATSUIInstanceIndex *pFontInstance
- );
-
void ATSUIFPrintFontList( const char *pFileName,
const char *pFilePermission,
const ItemCount nFontItemsCount,
diff --git a/vcl/aqua/inc/salconst.h b/vcl/aqua/inc/salconst.h
index e66c54bdb2f7..35b4035964d3 100755
--- a/vcl/aqua/inc/salconst.h
+++ b/vcl/aqua/inc/salconst.h
@@ -2,9 +2,9 @@
*
* $RCSfile: salconst.h,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bmahbod $ $Date: 2001-02-14 19:39:47 $
+ * last change: $Author: bmahbod $ $Date: 2001-03-26 21:53:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,37 +66,37 @@
// - Constants -
// -------------------
-const unsigned short kByteMask = 0xFF;
+static const unsigned short kByteMask = 0xFF;
-const unsigned short kOneByte = 8;
-const unsigned short kTwoBytes = 16;
+static const unsigned short kOneByte = 8;
+static const unsigned short kTwoBytes = 16;
-const unsigned short kOneBit = 1;
-const unsigned short kFiveBits = 5;
-const unsigned short kEightBits = 8;
-const unsigned short kTenBits = 10;
-const unsigned short kElevenBits = 11;
+static const unsigned short kOneBit = 1;
+static const unsigned short kFiveBits = 5;
+static const unsigned short kEightBits = 8;
+static const unsigned short kTenBits = 10;
+static const unsigned short kElevenBits = 11;
-const unsigned short kBlackAndWhite = 1;
-const unsigned short kFourBitColor = 4;
-const unsigned short kEightBitColor = 8;
-const unsigned short kThousandsColor = 16;
-const unsigned short kTrueColor = 32;
+static const unsigned short kBlackAndWhite = 1;
+static const unsigned short kFourBitColor = 4;
+static const unsigned short kEightBitColor = 8;
+static const unsigned short kThousandsColor = 16;
+static const unsigned short kTrueColor = 32;
-const unsigned long k16BitRedColorMask = 0x00007c00;
-const unsigned long k16BitGreenColorMask = 0x000003e0;
-const unsigned long k16BitBlueColorMask = 0x0000001f;
+static const unsigned long k16BitRedColorMask = 0x00007c00;
+static const unsigned long k16BitGreenColorMask = 0x000003e0;
+static const unsigned long k16BitBlueColorMask = 0x0000001f;
-const unsigned long k32BitRedColorMask = 0x00ff0000;
-const unsigned long k32BitGreenColorMask = 0x0000ff00;
-const unsigned long k32BitBlueColorMask = 0x000000ff;
+static const unsigned long k32BitRedColorMask = 0x00ff0000;
+static const unsigned long k32BitGreenColorMask = 0x0000ff00;
+static const unsigned long k32BitBlueColorMask = 0x000000ff;
-const unsigned short kPixMapCmpSizeOneBit = 1;
-const unsigned short kPixMapCmpSizeFourBits = 4;
-const unsigned short kPixMapCmpSizeFiveBits = 5;
-const unsigned short kPixMapCmpSizeEightBits = 8;
+static const unsigned short kPixMapCmpSizeOneBit = 1;
+static const unsigned short kPixMapCmpSizeFourBits = 4;
+static const unsigned short kPixMapCmpSizeFiveBits = 5;
+static const unsigned short kPixMapCmpSizeEightBits = 8;
-const long kPixMapHRes = 72;
-const long kPixMapVRes = 72;
+static const long kPixMapHRes = 72;
+static const long kPixMapVRes = 72;
#endif // _SV_SALCONST_H
diff --git a/vcl/aqua/inc/salfontutils.hxx b/vcl/aqua/inc/salfontutils.hxx
index c0e4af9ff5a8..30d27dd3415a 100644
--- a/vcl/aqua/inc/salfontutils.hxx
+++ b/vcl/aqua/inc/salfontutils.hxx
@@ -2,8 +2,8 @@
*
* $RCSfile: salfontutils.hxx,v $
*
- * $Revision: 1.2 $
- * last change: $Author: pluby $ $Date: 2001-03-13 09:44:40 $
+ * $Revision: 1.3 $
+ * last change: $Author: bmahbod $ $Date: 2001-03-26 21:53:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,6 +77,40 @@
// =======================================================================
+static const char *kFontWeightThin1 = "Thin";
+static const char *kFontWeightThin2 = "thin";
+
+static const char *kFontWeightLight1 = "Light";
+static const char *kFontWeightLight2 = "light";
+
+static const char *kFontWeightBold1 = "Bold";
+static const char *kFontWeightBold2 = "bold";
+
+static const char *kFontWeightUltra1 = "Ultra";
+static const char *kFontWeightUltra2 = "ultra";
+
+static const char *kFontWeightSemi1 = "Semi";
+static const char *kFontWeightSemi2 = "semi";
+
+static const char *kFontWeightNormal1 = "Normal";
+static const char *kFontWeightNormal2 = "normal";
+
+static const char *kFontWeightMedium1 = "Medium";
+static const char *kFontWeightMedium2 = "medium";
+
+static const char *kFontWeightBlack1 = "Black";
+static const char *kFontWeightBlack2 = "black";
+
+static const char *kFontWeightRoman1 = "Roman";
+static const char *kFontWeightRoman2 = "roman";
+
+static const char *kFontWeightRegular1 = "Regular";
+static const char *kFontWeightRegular2 = "regular";
+
+// =======================================================================
+
+// =======================================================================
+
DECLARE_LIST( FontList, ImplFontData* );
// =======================================================================
diff --git a/vcl/aqua/inc/salmathutils.hxx b/vcl/aqua/inc/salmathutils.hxx
index e879951aeb61..ddb9dcea2d45 100755
--- a/vcl/aqua/inc/salmathutils.hxx
+++ b/vcl/aqua/inc/salmathutils.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: salmathutils.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: pluby $ $Date: 2001-03-13 09:44:40 $
+ * last change: $Author: bmahbod $ $Date: 2001-03-26 21:53:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,7 +63,7 @@
#define _SV_SALMATHUTILS_HXX
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
// ------------------------------------------------------------------
diff --git a/vcl/aqua/source/gdi/salatsuifontutils.cxx b/vcl/aqua/source/gdi/salatsuifontutils.cxx
index e25f59216801..59bd4663a996 100644
--- a/vcl/aqua/source/gdi/salatsuifontutils.cxx
+++ b/vcl/aqua/source/gdi/salatsuifontutils.cxx
@@ -2,8 +2,8 @@
*
* $RCSfile: salatsuifontutils.cxx,v $
*
- * $Revision: 1.1 $
- * last change: $Author: bmahbod $ $Date: 2001-03-12 23:15:32 $
+ * $Revision: 1.2 $
+ * last change: $Author: bmahbod $ $Date: 2001-03-26 21:53:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,12 +72,6 @@
// =======================================================================
-static SInt16 AppendMenuName( MenuHandle hMenu,
- long nMenuLength,
- char pMenuName[],
- ScriptCode nMenuScriptCode
- );
-
static MacOSBoolean ATSUIBetterEncoding( const FontNameEncodingPtr pFontNewNameEncoding,
const FontNameEncodingPtr pFontOldNameEncoding,
const FontNameEncodingPtr pFontFamilyNameEncodingPrefs
@@ -108,19 +102,6 @@ static ItemCount ATSUILookForFontInstances( ATSUFontID *rFontIDList,
ItemCount nFontItemsCount
);
-static void FontListToHierarchialMenu( MenuHandle hFontMenu,
- short nHierarchiaFontMenuID,
- const FontNamesMatrix hFontList,
- ItemCount nFontItemsCount,
- short *rFontSubmenusCount,
- void **hFontMenuLookupCookie
- );
-
-static MenuHandle NewMenuName( short nMenuID,
- long nMenuItemLength,
- char nMenuTitle[]
- );
-
// =======================================================================
// =======================================================================
@@ -271,7 +252,7 @@ static FontNamesPtr ATSUIBuildFontNamesRecord( ATSUFontID nFontID,
FontScriptCode *pFontNameScriptCode = NULL;
FontLanguageCode *pFontNameLanguageCode = NULL;
- pFontFamilyNames->mnFontID = nFontID;
+ pFontFamilyNames->mnFontID = nFontID;
pFontFamilyNames->maFontFamilyNameEncoding.mnFontScriptCode = nFontFamilyScriptCode;
pFontFamilyNames->maFontFamilyNameEncoding.mnFontPlatformCode = nFontFamilyPlatformCode;
pFontFamilyNames->maFontFamilyNameEncoding.mnFontLanguageCode = nFontFamilyLanguageCode;
@@ -289,7 +270,7 @@ static FontNamesPtr ATSUIBuildFontNamesRecord( ATSUFontID nFontID,
if ( nStatus == noErr)
{
- pFontFamilyNames->mnFontStyleByteOffset = nFontFamilyNameLength;
+ pFontFamilyNames->mnFontStyleByteOffset = nFontFamilyNameLength;
pFontFamilyNames->maFontStyleNameEncoding.mnFontScriptCode = nFontStyleScriptCode;
pFontFamilyNames->maFontStyleNameEncoding.mnFontPlatformCode = nFontStylePlatformCode;
pFontFamilyNames->maFontStyleNameEncoding.mnFontLanguageCode = nFontStyleLanguageCode;
@@ -378,9 +359,9 @@ static long ATSUICompareFontNames( FontNamesPtr pFontName1,
pFontName2->maFontStyleNameEncoding.mnFontItemCount,
pFontName1->maFontStyleNameEncoding.mnFontScriptCode,
pFontName2->maFontStyleNameEncoding.mnFontScriptCode,
- pFontLangCode[0],
- pFontLangCode[1]
- );
+ pFontLangCode[0],
+ pFontLangCode[1]
+ );
} // if
return nTextOrder;
@@ -455,281 +436,6 @@ static void ATSUIInsertFontInSortedList( FontNamesPtr pFontNames,
// -----------------------------------------------------------------------
//
-// Create a new menu with the given ID and title
-//
-// -----------------------------------------------------------------------
-
-static MenuHandle NewMenuName( short nMenuID,
- long nMenuItemLength,
- char hMenuTitle[]
- )
-{
- MenuHandle hMenu = NULL;
-
- if ( IsPointerValid( (MacOSPtr)hMenuTitle ) )
- {
- Str255 pMenuItemNameBuffer;
-
- if ( nMenuItemLength < 255 )
- {
- pMenuItemNameBuffer[ 0 ] = nMenuItemLength;
- } // if
- else
- {
- pMenuItemNameBuffer[ 0 ] = 255;
- } // else
-
- BlockMove( hMenuTitle,
- &pMenuItemNameBuffer[ 1 ],
- pMenuItemNameBuffer[ 0 ]
- );
-
- hMenu = NewMenu( nMenuID, pMenuItemNameBuffer );
- } // if
-
- return hMenu;
-} // NewMenuName
-
-// -----------------------------------------------------------------------
-//
-// Append the given string to the menu
-//
-// -----------------------------------------------------------------------
-
-static SInt16 AppendMenuName( MenuHandle hMenu,
- long nMenuLength,
- char pMenuName[],
- ScriptCode nMenuScriptCode
- )
-{
- SInt16 nItemNum = 0;
-
- if ( ( IsHandleValid( (Handle)hMenu ) )
- && ( IsPointerValid( (MacOSPtr)pMenuName ) )
- )
- {
- OSErr nStatus = noErr;
- Str255 pMenuBufferName;
-
- if ( nMenuLength <= kMenuBufferMaxLength )
- {
- pMenuBufferName[ 0 ] = nMenuLength;
- } // if
- else
- {
- short nCharByteType = 0;
-
- pMenuBufferName[ 0 ] = kMenuBufferMaxLength;
-
- nCharByteType = CharacterByteType( pMenuName,
- kMenuBufferMaxLength,
- nMenuScriptCode
- );
-
- if ( nCharByteType > smSingleByte )
- {
- // truncate properly for multi-byte.
-
- --pMenuBufferName[ 0 ];
- } // if
- } // else
-
- BlockMoveData( pMenuName,
- &pMenuBufferName[ 1 ],
- pMenuBufferName[ 0 ]
- );
-
- // avoid metacharacter processing
-
- AppendMenu( hMenu, kMenuItemGenericName );
-
- nItemNum = CountMenuItems( hMenu );
-
- SetMenuItemText( hMenu,
- nItemNum,
- pMenuBufferName
- );
-
- nStatus = SetMenuItemTextEncoding( hMenu,
- nItemNum,
- nMenuScriptCode
- );
- } // if
-
- return nItemNum;
-} // AppendMenuName
-
-// -----------------------------------------------------------------------
-//
-// Construct the font hierarchial menu using our font ID list.
-//
-// -----------------------------------------------------------------------
-
-static void FontListToHierarchialMenu( MenuHandle hFontMenu,
- short nHierarchiaFontMenuID,
- const FontNamesMatrix hFontList,
- ItemCount nFontItemsCount,
- short *rFontSubmenusCount,
- void **hFontMenuLookupCookie
- )
-{
- hFontMenuLookupCookie = NULL;
- *rFontSubmenusCount = 0;
-
- if ( nFontItemsCount > 0 )
- {
- long nFontMenuHandleSize = nFontItemsCount * sizeof(FontMenuItemRecord);
- OSStatus nStatus = noErr;
- FontMenuItemsHandle hFontMenuItems = NULL;
-
- hFontMenuItems = (FontMenuItemsHandle)NewHandleClear( nFontMenuHandleSize );
-
- nStatus = MemError();
-
- if ( ( nStatus == noErr )
- && ( IsHandleValid( (Handle)hFontMenuItems ) )
- )
- {
- SInt8 nFlags = noErr;
-
- nFlags = HGetState( (Handle)hFontMenuItems );
-
- if ( nFlags == noErr )
- {
- long i = 0;
- long j = 0;
- long k = 0;
- long nFontMenuItem = 0;
- long nRecordNum = 0;
- long nTextOrder = 0;
- long nFontSubItemNum = 0;
- short nFontSubMenuID = 0;
- short nFontSubmenusCreated = 0;
- LangCode aFontLangCode[2] = { currentDefLang, currentDefLang };
- MenuHandle hFontSubMenu = NULL;
- OSStatus nStatus = noErr;
-
- HLock( (Handle)hFontMenuItems );
-
- while ( i < nFontItemsCount )
- {
- // Collect up the fonts with the same family name
-
- for ( j = i + 1; j < nFontItemsCount; j++ )
- {
- nTextOrder = TextOrder( &hFontList[ i ]->mpFontName[ 0 ],
- &hFontList[ j ]->mpFontName[ 0 ],
- hFontList[ i ]->maFontFamilyNameEncoding.mnFontItemCount,
- hFontList[ j ]->maFontFamilyNameEncoding.mnFontItemCount,
- hFontList[ i ]->maFontFamilyNameEncoding.mnFontScriptCode,
- hFontList[ j ]->maFontFamilyNameEncoding.mnFontScriptCode,
- aFontLangCode[0],
- aFontLangCode[1]
- );
-
- if ( nTextOrder != 0 )
- {
- break;
- } // if
- } // for
-
- // Should the style name be added to the top level if there's only one style?
- // How about using full name instead?
-
- nFontMenuItem = AppendMenuName( hFontMenu,
- hFontList[ i ]->maFontFamilyNameEncoding.mnFontItemCount,
- &hFontList[ i ]->mpFontName[ 0 ],
- hFontList[ i ]->maFontFamilyNameEncoding.mnFontScriptCode
- );
-
- // Add a submenu for the styles
-
- if ( j - i > 1 )
- {
- nFontSubMenuID = nHierarchiaFontMenuID + nFontSubmenusCreated++;
-
- hFontSubMenu = NewMenuName( nFontSubMenuID,
- hFontList[ i ]->maFontFamilyNameEncoding.mnFontItemCount,
- &hFontList[ i ]->mpFontName[ 0 ]
- );
-
- if ( hFontSubMenu != NULL )
- {
- for ( k = i; k < j; k++ )
- {
- nFontSubItemNum
- = AppendMenuName( hFontSubMenu,
- hFontList[ k ]->maFontStyleNameEncoding.mnFontItemCount,
- &hFontList[ k ]->mpFontName[ hFontList[ k ]->mnFontStyleByteOffset ],
- hFontList[ k ]->maFontStyleNameEncoding.mnFontScriptCode
- );
-
- if ( ( kATSUIFontInstanceMenuItemStyle != 0 )
- && ( hFontList[ k ]->mnFontInstanceIndex != kATSUIDefaultInstance )
- )
- {
- SetItemStyle( hFontSubMenu,
- nFontSubItemNum,
- kATSUIFontInstanceMenuItemStyle
- );
- } //if
-
- // leave a trail so we can recover the font ID
-
- (*hFontMenuItems)[ nRecordNum ].mnFontID = hFontList[ k ]->mnFontID;
- (*hFontMenuItems)[ nRecordNum ].mnFontInstanceIndex = hFontList[ k ]->mnFontInstanceIndex;
- (*hFontMenuItems)[ nRecordNum ].mnFontMenuID = nFontSubMenuID;
- (*hFontMenuItems)[ nRecordNum ].mnFontItemNum = nFontSubItemNum;
-
- nRecordNum += 1;
- } // for
-
- InsertMenu( hFontSubMenu, hierMenu );
-
- nStatus = SetMenuItemHierarchicalID( hFontMenu,
- nFontMenuItem,
- nFontSubMenuID
- );
- } //if
- } // if
- else
- {
- // leave a trail so we can recover the font ID
-
- (*hFontMenuItems)[ nRecordNum ].mnFontID = hFontList[ i ]->mnFontID;
- (*hFontMenuItems)[ nRecordNum ].mnFontInstanceIndex = hFontList[ i ]->mnFontInstanceIndex;
- (*hFontMenuItems)[ nRecordNum ].mnFontMenuID = GetMenuID(hFontMenu);
- (*hFontMenuItems)[ nRecordNum ].mnFontItemNum = nFontMenuItem;
-
- nRecordNum += 1;
-
- } // else
-
- i = j; // next family name
- } // while
-
- if ( rFontSubmenusCount != NULL )
- {
- *rFontSubmenusCount = nFontSubmenusCreated;
- } // if
-
- *hFontMenuLookupCookie = hFontMenuItems;
-
- HSetState( (Handle)hFontMenuItems, nFlags );
- } // if
- else
- {
- // If we can't lock the font menu items handle, dispose of it
- // and exit
-
- DisposeHandle( (Handle)hFontMenuItems );
- } // else
- } // if
- } // if
-} // FontListToHierarchialMenu
-
-// -----------------------------------------------------------------------
-//
// Loop throught our font ID list, count the font instances, and if a
// "bad" font is encountered, remove it from the font ID list.
//
@@ -931,274 +637,6 @@ static ATSUIInstanceIndex ATSUIInstanceMatchingDefaultVariations( ATSUFontID nFo
} // ATSUIInstanceMatchingDefaultVariations
// -----------------------------------------------------------------------
-//
-// Here we shall construct a hierarchial font menu. The top level of our
-// font menu consists of font family name, and if there's more than one
-// style for a given family, a submenu is created for those styles. We
-// will treat font instances as styles.
-//
-// Note that:
-//
-// * If there's only one representative of a family, we shall insert the
-// full font name into the menu instead of only the family name. We can
-// not determine this immediately until all the fonts are sorted.
-//
-// * If there are multiple fonts with the same name, all but the first
-// occurance of this particular font is kept.
-//
-// -----------------------------------------------------------------------
-
-OSStatus ATSUIAppendFontMenu( MenuHandle hFontMenu,
- short nHierarchiaFontMenuID,
- short *rSubmenuCount,
- void **hFontMenuLookupCookie
- )
-{
- OSStatus nStatus = noErr;
- ItemCount nFontItemsSize = 0;
-
- nStatus = ATSUFontCount( &nFontItemsSize );
-
- if ( ( nStatus == noErr )
- && ( nFontItemsSize > 0 )
- )
- {
- ATSUFontID *pFontIDList = NULL;
- long nFontIDListSize = nFontItemsSize * sizeof(ATSUFontID);
-
- pFontIDList = (ATSUFontID *)NewPtrClear( nFontIDListSize );
-
- nStatus = MemError();
-
- if ( ( nStatus == noErr )
- && ( IsPointerValid( (MacOSPtr)pFontIDList ) )
- )
- {
- ItemCount *pFontItemsCount = NULL;
-
- nStatus = ATSUGetFontIDs( pFontIDList,
- nFontItemsSize,
- pFontItemsCount
- );
-
- if ( nStatus == noErr )
- {
- long nSortedFontListSize = 0;
- ItemCount nTotalFontInstances = 0;
- ItemCount nSortedFontListLength = 0;
- FontNamesMatrix hSortedFontList = NULL;
-
- nTotalFontInstances = ATSUILookForFontInstances( pFontIDList, nFontItemsSize );
-
- // The allocated size for the sorted font list might be larger than
- // neccessary because of "bad" fonts, but at least we have had more
- // than enough memory storage.
-
- nSortedFontListSize = (nFontItemsSize + nTotalFontInstances)
- * sizeof(FontNamesPtr);
-
- hSortedFontList = (FontNamesMatrix)NewPtrClear( nSortedFontListSize );
-
- nStatus = MemError();
-
- if ( ( nStatus == noErr )
- && ( IsPointerValid( (MacOSPtr)hSortedFontList ) )
- )
- {
- ATSUIInstanceIndex nFontInstanceIndex = 0;
- FontNamesPtr pFontNames = NULL;
- FontNameCode nFontInstanceNameCode = 0;
- ItemCount nFontInstance = 0;
- ItemCount nFontInstancesCount = 0;
- ItemCount nFontIndex;
-
- for ( nFontIndex = 0;
- nFontIndex < nFontItemsSize;
- nFontIndex++
- )
- {
- if ( pFontIDList[ nFontIndex ] != kATSUInvalidFontID )
- {
- // If there exists a name list then add the font's
- // instances to this particular list.
-
- nStatus = ATSUCountFontInstances( pFontIDList[ nFontIndex ],
- &nFontInstancesCount
- );
-
- for ( nFontInstance = 0;
- nFontInstance < nFontInstancesCount;
- ++nFontInstance
- )
- {
- nStatus = ATSUGetFontInstanceNameCode( pFontIDList[ nFontIndex ],
- nFontInstance,
- &nFontInstanceNameCode
- );
-
- if ( nStatus == noErr )
- {
- pFontNames = ATSUIBuildFontNamesRecord( pFontIDList[ nFontIndex ],
- nFontInstance,
- nFontInstanceNameCode
- );
-
- if ( pFontNames != NULL )
- {
- ATSUIInsertFontInSortedList( pFontNames,
- hSortedFontList,
- &nSortedFontListLength
- );
- } // if
- } // if
- } // if
-
- // Now add the font. However, and if this font has the same name as
- // an instance index, skip this font, and defer any actions until
- // name collisions issue is resolved.
-
- nFontInstanceIndex
- = ATSUIInstanceMatchingDefaultVariations( pFontIDList[ nFontIndex ] );
-
- if ( nFontInstanceIndex == kATSUIDefaultInstance )
- {
- pFontNames = ATSUIBuildFontNamesRecord( pFontIDList[ nFontIndex ],
- kATSUIDefaultInstance,
- kFontStyleName
- );
-
- if ( pFontNames != NULL )
- {
- ATSUIInsertFontInSortedList( pFontNames,
- hSortedFontList,
- &nSortedFontListLength
- );
- } // if
- } // if
- } // if
- } // for
-
- FontListToHierarchialMenu( hFontMenu,
- nHierarchiaFontMenuID,
- hSortedFontList,
- nSortedFontListLength,
- rSubmenuCount,
- hFontMenuLookupCookie
- );
-
- for ( nFontIndex = 0;
- nFontIndex < nSortedFontListLength;
- nFontIndex++
- )
- {
- if ( hSortedFontList[ nFontIndex ] != NULL )
- {
- DisposePtr( (MacOSPtr)hSortedFontList[ nFontIndex ] );
- } // if
- } // for
-
- DisposePtr( (MacOSPtr)hSortedFontList );
- } // if
- } // if
-
- DisposePtr( (MacOSPtr)pFontIDList );
- } // if
- } // if
-
- return nStatus;
-} // ATSUIAppendFontMenu
-
-// -----------------------------------------------------------------------
-
-ATSUFontID ATSUIGetFontForFontMenuItem( short nMenuID,
- short nMenuItemNum,
- void *pMenuLookupCookie,
- ATSUIInstanceIndex *rFontInstance
- )
-{
- if ( ( IsPointerValid( (MacOSPtr)pMenuLookupCookie ) )
- && ( IsPointerValid( (MacOSPtr)rFontInstance ) )
- )
- {
- // Have to search for this font in the data structure we're
- // about to build.
-
- FontMenuItemsHandle hFontMenuItems = (FontMenuItemsHandle)pMenuLookupCookie;
-
- if ( IsHandleValid( (Handle)hFontMenuItems ) )
- {
- SInt8 nFlags = noErr;
-
- nFlags = HGetState( (Handle)hFontMenuItems );
-
- if ( nFlags == noErr )
- {
- short nFontMenuItemHandleSize = GetHandleSize( (Handle)hFontMenuItems );
- short nFontMenuItemRecSize = sizeof(FontMenuItemRecord);
- short nMenuEntriesCount = nFontMenuItemHandleSize / nFontMenuItemRecSize;
- short nMenuEntriesIndex;
-
- HLock( (Handle)hFontMenuItems );
-
- // To find the font, perform a linear search.
-
- for ( nMenuEntriesIndex = 0;
- nMenuEntriesIndex < nMenuEntriesCount;
- ++nMenuEntriesIndex
- )
- {
- if ( ( nMenuID == (*hFontMenuItems)[nMenuEntriesIndex ].mnFontMenuID )
- && ( nMenuItemNum == (*hFontMenuItems)[ nMenuEntriesIndex ].mnFontItemNum )
- )
- {
- if ( rFontInstance != NULL )
- {
- *rFontInstance = (*hFontMenuItems)[ nMenuEntriesIndex ].mnFontInstanceIndex;
- } // if
-
- // Set font menu items handle state before leaving
-
- HSetState( (Handle)hFontMenuItems, nFlags );
-
- return (*hFontMenuItems)[ nMenuEntriesIndex ].mnFontID;
- } // if
- } // for
-
- // If we get here then our linear search yielded no results
-
- HSetState( (Handle)hFontMenuItems, nFlags );
- }// if
- } // if
- } // if
-
- // If we get here, either we didn't find the font, an invalid
- // pointer was passed in, or there was a problem with the handle
- // we constructed.
-
- return kATSUInvalidFontID;
-} // ATSUIGetFontForFontMenuItem
-
-// -----------------------------------------------------------------------
-
-OSStatus ATSUIDisposeFontMenuLookupCookie( void *pMenuLookupCookie )
-{
- OSStatus nStatus = noErr;
-
- if ( IsHandleValid( (Handle)pMenuLookupCookie ) )
- {
- DisposeHandle( (Handle) pMenuLookupCookie );
-
- nStatus = MemError();
- } // if
- else
- {
- nStatus = nilHandleErr;
- } // else
-
- return nStatus;
-} // ATSUIDisposeFontMenuLookupCookie
-
-// -----------------------------------------------------------------------
OSStatus ATSUISetStyleFontInstance( ATSUStyle aFontStyle,
ATSUFontID nFontID,