home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-02-09 | 43.0 KB | 1,483 lines | [TEXT/CWIE] |
- /*
- File: UnicodeHub.cp
-
- Contains:
-
- Version: System 8
-
- Copyright: © 1997-1999 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: Julio Gonzalez
-
- Other Contact: Peter Edberg
-
- Technology: International
-
- Writers:
-
- (jag) Julio Gonzalez
-
- Change History (most recent first):
-
- <TEC3> 2/9/99 jag Modify GetMappings so that it orders encodings first on base,
- followed by variant, followed by Format. Add version to about
- box.
- <TEC2> 6/24/98 jag Use InsertMenuItem + SetMenuItemText instead of just
- InsertMenuItem so that we can get all the chars in the name
- without having to worry about menu manager meta characters.
- <TEC1> 6/16/98 jag first checked in
- <TEC0> 6/16/98 jag Moved to BBS (new change numbers!).
-
- Old history in NRBuild:
- <2+> 12/12/97 jag Add HFS+ Unicode Item to the list as TECCountAvailableEncodings
- ignores all UnicodeHFS+ variants.
- <2> 8/20/97 jag Change the style from outline to bold when displaying strings
- that are encoded in non-Mac OS encodings.
- */
-
- // ===========================================================================
- // <PP Starter Source>.cp ©1994-1995 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
- // This file contains the starter code for a PowerPlant application
-
- #include "UnicodeHub.h"
- #include "UnicodeHubConstants.h"
-
- #include <Sound.h>
- #include <Script.h> // Script Manager definitions
-
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
- #include <PP_Resources.h>
- #include <PPobClasses.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <UReanimator.h>
- #include <UDesktop.h>
- #include <URegistrar.h>
- #include <LEditField.h>
- #include <LTextEdit.h>
- #include <UTextTraits.h>
- #include "LDynamicArray.h"
-
- unsigned char UnicodeErrors [][32] = {
- "\p",
- "\p",
- "\p",
- "\p",
- "\pkTECOutputBufferFullStatus",
- "\pkTECNeedFlushStatus",
- "\pkTECUsedFallbacksStatus",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\p",
- "\pkTECItemUnavailableErr",
- "\pkTECGlobalsUnavailableErr",
- "\punicodeChecksumErr",
- "\punicodeNoTableErr",
- "\punicodeVariantErr",
- "\punicodeFallbacksErr",
- "\punicodePartConvertErr",
- "\punicodeBufErr",
- "\punicodeCharErr",
- "\punicodeElementErr",
- "\punicodeNotFoundErr",
- "\punicodeTableFormatErr",
- "\punicodeDirectionErr",
- "\punicodeContextualErr",
- "\punicodeTextEncodingDataErr",
- "\pkTECDirectionErr",
- "\pkTECIncompleteElementErr",
- "\pkTECUnmappableElementErr",
- "\pkTECPartialCharErr",
- "\pkTECBadTextRunErr",
- "\pkTECArrayFullErr",
- "\pkTECBufferBelowMinimumSizeErr",
- "\pkTECNoConversionPathErr",
- "\pkTECCorruptConverterErr",
- "\pkTECTableFormatErr",
- "\pkTECTableChecksumErr",
- "\pkTECMissingTableErr",
- "\p",
- "\p",
- "\p",
- "\p",
- "\kTextUndefinedElementErrp",
- "\pkTextMalformedInputErr",
- "\pkTextUnsupportedEncodingErr",
-
- "\pkIllegalHexString"
- };
-
-
-
-
- CPPStarterApp* gTheApp=0;
-
-
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Nothing);
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
-
- CPPStarterApp theApp; // replace this with your App type
-
- gTheApp = &theApp; // Save a pointer to the application -- there might be a better
- // way to get a the app -- like getting to the top level commander?
-
- theApp.GetMappings(); // Get all the available Unicode Mappings
-
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------
- // • CPPStarterApp // replace this with your App type
- // ---------------------------------------------------------------------------
-
- // Constructor
-
- CPPStarterApp::CPPStarterApp()
- {
- // Register functions to create core PowerPlant classes
-
- RegisterAllPPClasses();
-
- URegistrar::RegisterClass(
- CUnicodeTablesPopup::class_ID,
- (ClassCreatorFunc) CUnicodeTablesPopup::CreateUnicodeTablesPopupStream );
-
- URegistrar::RegisterClass(
- CFontMenuPopup::class_ID,
- (ClassCreatorFunc) CFontMenuPopup::CreateFontMenuPopupStream );
-
- URegistrar::RegisterClass(
- CUnicodeHubWindow::class_ID,
- (ClassCreatorFunc) CUnicodeHubWindow::CreateUnicodeHubWindowStream );
-
- URegistrar::RegisterClass(
- CStyleText::class_ID,
- (ClassCreatorFunc) CStyleText::CreateStyleTextEditStream );
-
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CPPStarterApp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CPPStarterApp::~CPPStarterApp()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // This function lets you do something when the application starts up.
- // For example, you could issue your own new command, or respond to a system
- // oDoc (open document) event.
-
- void
- CPPStarterApp::StartUp()
- {
- ObeyCommand(cmd_New, nil); // EXAMPLE, create a new window
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CPPStarterApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // Deal with command messages (defined in PP_Messages.h).
- // Any that you don't handle will be passed to LApplication
-
- case cmd_New:
- // EXAMPLE, create a new window
- CUnicodeHubWindow *theWindow;
- theWindow = (CUnicodeHubWindow *)CUnicodeHubWindow::CreateWindow(rPPob_UnicodeHubWindow, this);
- UReanimator::LinkListenerToControls( (CUnicodeHubWindow*)theWindow, (LWindow*)theWindow, rRidL_UnicodeHubWindow);
- theWindow->Show();
- break;
-
-
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // This function enables menu commands.
- //
-
- void
- CPPStarterApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
-
- switch (inCommand) {
-
- // Return menu item status according to command messages.
- // Any that you don't handle will be passed to LApplication
-
- case cmd_New: // EXAMPLE
- outEnabled = false; // disable the New command - currently PP crashes when the 2nd
- // window comes up - so disable it it - I don't need 2 windows
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
-
-
- // ---------------------------------------------------------------------------------
- // • GetMappings
- // ---------------------------------------------------------------------------------
-
- #if 0
- void PrepareForMenuDisplay( StringPtr str );
- void PrepareForMenuDisplay( StringPtr str )
- {
- int len=*str;
-
- while(len>0)
- {
- str++;
- if( *str == '\/' || *str == '\\' || *str == ';' )
- *str = '-';
- else if( *str == '(' )
- *str = '[';
- else if( *str == ')' )
- *str = ']';
- else if( *str == '^' || *str == '<' || *str == '!' )
- *str = ' ';
- len--;
- }
- }
- #endif
-
- OSStatus
- CPPStarterApp::GetMappings()
- {
- OSStatus status;
- ByteCount outputLen;
- UnicodeMapping findMapping = {0};
- short i=0;
- int position;
-
- /**********************************************************************************************************
- * TEC SPECIFIC CODE COMMENT
- *
- * Obtain a list of all the available encoding conversions that we may be able to perform.
- * This includes, all conversions that the Text Encoding Converter and the Unicode Converter
- * can perform. First I call TECCountAvailableTextEncodings to get the number of encodings that
- * are supported. I really don't need to do that sinve I've statically allocated the size of the
- * buffer. However, we presume that most people will need to make this call to assertain how big
- * of a buffer to allocate before calling TECGetAvailableTextEncodings.
- **********************************************************************************************************/
-
- status = TECCountAvailableTextEncodings( &mNumMappings);
- ThrowIfError_(status);
-
- status = TECGetAvailableTextEncodings(mAvailableMappings, mNumMappings, &mNumMappings);
- ThrowIfError_(status);
-
- //Manually add the HFS+ Unicode format as TECGetAvailableTextEncodings ignores any Unicode variant and format
- //that it currently doesn't handle.
- mNumMappings++;
- mAvailableMappings[mNumMappings-1]=CreateTextEncoding( kTextEncodingUnicodeV2_0, kUnicodeCanonicalDecompVariant, kTextEncodingDefaultFormat);
-
- /**********************************************************************************************************
- * END TEC SPECIFIC CODE COMMENTED BLOCK
- **********************************************************************************************************/
-
-
- //**** LAME SORT - sort all the encodings returned by the Text Encoding numerical value.
- LDynamicArray *myMappingsList=new LDynamicArray( (Uint32)( sizeof(mAvailableMappings[0]) ) );
-
- i=0;
- while( i++< mNumMappings )
- {
- TextEncoding theMapping;
-
- for ( position=1; position<=myMappingsList->GetCount(); position++ )
- {
- myMappingsList->FetchItemAt( position, &theMapping );
- if( GetTextEncodingBase(theMapping) < GetTextEncodingBase(mAvailableMappings[i-1]) )
- break;
- else if( GetTextEncodingBase(theMapping) == GetTextEncodingBase(mAvailableMappings[i-1]) )
- {
- if( GetTextEncodingVariant(theMapping) < GetTextEncodingVariant(mAvailableMappings[i-1]) )
- break;
- else if( GetTextEncodingVariant(theMapping) == GetTextEncodingVariant(mAvailableMappings[i-1]) )
- {
- if( GetTextEncodingFormat(theMapping) < GetTextEncodingFormat(mAvailableMappings[i-1]) )
- break;
- }
- }
- }
-
- myMappingsList->InsertItemsAt( 1, position, &mAvailableMappings[i-1] );
- }
-
- i=0;
- position =mNumMappings;
- while(i++<mNumMappings)
- {
- myMappingsList->FetchItemAt( position--, &mAvailableMappings[i-1] );
- }
-
- delete myMappingsList;
- //*** END OF LAME SORT
-
- /**********************************************************************************************************
- * TEC SPECIFIC CODE COMMENT
- *
- * In the following loop, we'll get the name for every one of the encodings in our array. We use the
- * GetTextEncodingName name API. Currently, most tables/plugins have defined in them a name in the
- * kTextEncodingUS_ASCII encoding. We also check for kTextEncodingMacRoman just in case.
- * First we get the name for the base encoding, later we proceed to get the name for the variant and
- * format if any. Currently, there are no names for variant and formats entered in the tables. So, I've
- * added code that just displays the HEX value for the encoding.
- **********************************************************************************************************/
-
- i=0;
- while(i++<mNumMappings)
- {
- TextEncoding nameEncoding;
- RegionCode oActualRegion;
-
- //Get the name of the encoding base
- status = GetTextEncodingName(mAvailableMappings[i-1], kTextEncodingBaseName, verUS, kTextEncodingUS_ASCII,
- kMaxLen, &outputLen, &oActualRegion,&nameEncoding, (TextPtr) (mAvailableMappingNames[i-1])+1);
-
- if( status == noErr && ( nameEncoding == kTextEncodingMacRoman || nameEncoding == kTextEncodingUS_ASCII))
- {
- Str63 variantFormatName;
- ByteCount oldOutputLen=outputLen;
-
- *((mAvailableMappingNames[i-1]))=outputLen;
-
- //Get the name of the variant
- status = GetTextEncodingName(mAvailableMappings[i-1], kTextEncodingVariantName, verUS, kTextEncodingUS_ASCII,
- kMaxLen, &outputLen, &oActualRegion,&nameEncoding, (TextPtr) (variantFormatName)+1);
- if( status == noErr )
- {
- BlockMove( (variantFormatName)+1, ((mAvailableMappingNames[i-1]))+*((mAvailableMappingNames[i-1]))+1, outputLen );
- *((mAvailableMappingNames[i-1]))+=outputLen;
- }
-
- //Get the name of the format
- status = GetTextEncodingName(mAvailableMappings[i-1], kTextEncodingFormatName, verUS, kTextEncodingUS_ASCII,
- kMaxLen, &outputLen, &oActualRegion,&nameEncoding, (TextPtr) (variantFormatName)+1);
- if( status == noErr )
- {
- BlockMove( (variantFormatName)+1, ((mAvailableMappingNames[i-1]))+*((mAvailableMappingNames[i-1]))+1, outputLen );
- *((mAvailableMappingNames[i-1]))+=outputLen;
- }
-
-
- //If the encoding has either a base or a variant but no text was returned from the calls
- //above, then append the encoding number in Hex.
- if( ( ( GetTextEncodingVariant(mAvailableMappings[i-1]) != kTextEncodingDefaultVariant) ||
- ( GetTextEncodingFormat(mAvailableMappings[i-1]) != kTextEncodingDefaultFormat) ) &&
- oldOutputLen == *((mAvailableMappingNames[i-1])) )
- {
- BlockMove( " 0x", ((mAvailableMappingNames[i-1]))+*((mAvailableMappingNames[i-1]))+1, 3);
- BufToHex( (unsigned char*)&mAvailableMappings[i-1], (unsigned char*) ((mAvailableMappingNames[i-1]))+*((mAvailableMappingNames[i-1]))+4,
- 4, outputLen, 0);
- *((mAvailableMappingNames[i-1]))+=11;
- }
-
- //PrepareForMenuDisplay( mAvailableMappingNames[i-1] );
- }
- else
- {
- *((mAvailableMappingNames[i-1]))=10;
- ::BlockMove( "0x", (((mAvailableMappingNames[i-1]))+1), 2);
- BufToHex( (unsigned char*)&mAvailableMappings[i-1], (unsigned char*) (((mAvailableMappingNames[i-1]))+3),
- 4, outputLen, 0);
- //PrepareForMenuDisplay( mAvailableMappingNames[i-1] );
- }
- }
- /**********************************************************************************************************
- * END TEC SPECIFIC CODE COMMENTED BLOCK
- **********************************************************************************************************/
-
-
- error:
- return status;
- }
-
-
- /********************************************************
- OptionKeyDown
- ********************************************************/
- Boolean OptionKeyDown(void);
- Boolean OptionKeyDown(void)
- {
- return ((*(long *)0x178 & 4L) != 0L);
- }
-
-
- #define PLAYSOUND 0
-
- void CPPStarterApp::ShowAboutBox()
- {
-
- //inherited::ShowAboutBox();
-
- #if PLAYSOUND
- Handle theSound=::GetNamedResource('snd ',"\pAboutSound");
- if(theSound)
- ::HNoPurge(theSound);
- #endif
-
- UDesktop::Deactivate(); // Alert will swallow Deactivate event
-
-
- DialogPtr dPtr=::GetNewDialog( ALRT_About, nil, (WindowPtr)-1L);
- FailNIL_( dPtr );
-
- ::SetDialogDefaultItem( dPtr, 1);
- ::DrawDialog(dPtr);
-
- #if PLAYSOUND
- if(theSound)
- {
- ::SetCursor(*(::GetCursor(watchCursor)));
- ::SndPlay( nil, (SndListResource**)theSound, false);
- ::HPurge(theSound);
- ::ReleaseResource( theSound );
- ::InitCursor();
- }
- #endif
-
- Handle versH;
- Str31 versStr;
-
- versH=::Get1Resource( 'vers', 1);
- if( versH != NULL )
- {
- ::HLock( versH );
- StringPtr versStrP=(StringPtr)*versH;
-
- versStrP+=6; //move to beginning of short version string
- versStrP+=(*versStrP+1); //move to beginning of long version string
-
- ::BlockMoveData( versStrP, versStr, *versStrP + 1 );
-
- ::ReleaseResource( versH );
- }
- else
- *versStr=0;
-
- ::ParamText( versStr, "\p", "\p", "\p" );
-
-
- short itemHit=0;
- while(itemHit!=1)
- ::ModalDialog( nil, &itemHit );
-
- if( OptionKeyDown() )
- DebugStr("\pLet's do some debugging");
-
- DisposeDialog( dPtr );
-
- UDesktop::Activate();
- }
-
-
-
-
-
-
- // *********************************************************************************
- // • CUnicodeTablesPopup
- // *********************************************************************************
-
-
- CUnicodeTablesPopup*
- CUnicodeTablesPopup::CreateUnicodeTablesPopupStream(LStream *inStream)
- {
- return ( new CUnicodeTablesPopup( inStream ));
- }
-
- CUnicodeTablesPopup::CUnicodeTablesPopup(const SPaneInfo &inPaneInfo,
- MessageT inValueMessage, Int16 inTitleOptions,
- ResIDT inMENUid, Int16 inTitleWidth,
- Int16 inPopupVariation, ResIDT inTextTraitsID,
- Str255 inTitle, OSType inResTypeMENU,
- Int16 inInitialMenuItem) :
- LStdPopupMenu(inPaneInfo, inValueMessage, inTitleOptions,
- inMENUid, inTitleWidth, inPopupVariation, inTextTraitsID,
- inTitle, inResTypeMENU, inInitialMenuItem)
- {
- FillMenuWithUnicodeTables();
- }
-
- CUnicodeTablesPopup::CUnicodeTablesPopup(const SPaneInfo &inPaneInfo,
- MessageT inValueMessage, Int32 inMaxValue,
- ResIDT inTextTraitsID, ControlHandle inMacControlH ) :
- LStdPopupMenu(inPaneInfo, inValueMessage, inMaxValue,
- inTextTraitsID, inMacControlH)
- {
- FillMenuWithUnicodeTables();
- }
-
-
- CUnicodeTablesPopup::CUnicodeTablesPopup(LStream *inStream) : LStdPopupMenu( inStream )
- {
- FillMenuWithUnicodeTables();
- }
-
-
-
- CUnicodeTablesPopup::~CUnicodeTablesPopup()
- {
- }
-
- void CUnicodeTablesPopup::FillMenuWithUnicodeTables(void)
- {
- MenuHandle theMenuH=GetMacMenuH();
-
- if(!theMenuH) return;
-
-
- for( UInt32 i=0; i<gTheApp->mNumMappings; i++)
- {
- ::InsertMenuItem(theMenuH, "\px", i+2);
- ::SetMenuItemText(theMenuH, i+2, gTheApp->mAvailableMappingNames[i]);
- if( gTheApp->IsUnicode( gTheApp->mAvailableMappings[i] ) )
- ::SetItemStyle( theMenuH, i+2, bold );
- }
-
- SetMaxValue(gTheApp->mNumMappings+1);
- }
-
-
- // *********************************************************************************
- // • CFontMenuPopup
- // *********************************************************************************
-
-
- CFontMenuPopup*
- CFontMenuPopup::CreateFontMenuPopupStream(LStream *inStream)
- {
- return ( new CFontMenuPopup( inStream ));
- }
-
- CFontMenuPopup::CFontMenuPopup(const SPaneInfo &inPaneInfo,
- MessageT inValueMessage, Int16 inTitleOptions,
- ResIDT inMENUid, Int16 inTitleWidth,
- Int16 inPopupVariation, ResIDT inTextTraitsID,
- Str255 inTitle, OSType inResTypeMENU,
- Int16 inInitialMenuItem) :
- LStdPopupMenu(inPaneInfo, inValueMessage, inTitleOptions,
- inMENUid, inTitleWidth, inPopupVariation, inTextTraitsID,
- inTitle, inResTypeMENU, inInitialMenuItem)
- {
- FillFontMenu();
- }
-
- CFontMenuPopup::CFontMenuPopup(const SPaneInfo &inPaneInfo,
- MessageT inValueMessage, Int32 inMaxValue,
- ResIDT inTextTraitsID, ControlHandle inMacControlH ) :
- LStdPopupMenu(inPaneInfo, inValueMessage, inMaxValue,
- inTextTraitsID, inMacControlH)
- {
- FillFontMenu();
- }
-
-
- CFontMenuPopup::CFontMenuPopup(LStream *inStream) : LStdPopupMenu( inStream )
- {
- FillFontMenu();
- }
-
-
-
- CFontMenuPopup::~CFontMenuPopup()
- {
- }
-
-
-
- void CFontMenuPopup::FillFontMenu(void)
- {
- UInt16 fontsInstalled;
- UInt16 applFontIndex=1;
- MenuHandle theMenuH=GetMacMenuH();
-
- if(!theMenuH) return;
-
- ::AppendResMenu( theMenuH, 'FONT');
- fontsInstalled=::CountMItems(theMenuH);
- SetMaxValue(fontsInstalled);
-
- /**********************************************************************************************************
- * TEC SPECIFIC CODE COMMENT
- *
- * Here we loop through the font menu and build an array with TextEncodings that match every one
- * of the Font menu names. In order to do this we use UpgradeScriptInfoToTextEncoding. Also, just for
- * kicks, I check to see if the encoding has a variant or that doesn't correspond to a Mac script code.
- * If so, I make the item italic and bold for easy identification.
- **********************************************************************************************************/
- for( int i=1; i<=fontsInstalled; i++ )
- {
- Str31 fontName;
- OSStatus status;
- TextEncoding theEncoding;
-
- ::GetMenuItemText(theMenuH, i, fontName);
- ::GetFNum(fontName, &mInstalledFonts[i-1] ) ;
-
- if( GetAppFont() == mInstalledFonts[i-1] )
- applFontIndex=i;
-
- status = UpgradeScriptInfoToTextEncoding( kTextScriptDontCare, kTextLanguageDontCare, kTextRegionDontCare, fontName, &theEncoding );
- if( status == noErr )
- {
- if( (theEncoding > smUninterp) || (GetTextEncodingVariant(theEncoding) != kTextEncodingDefaultVariant) )
- ::SetItemStyle( theMenuH, i, bold+italic);
- }
- else
- ::SetItemStyle( theMenuH, i, outline );
-
- }
- /**********************************************************************************************************
- * END TEC SPECIFIC CODE COMMENTED BLOCK
- **********************************************************************************************************/
-
- LStdPopupMenu::SetValue( applFontIndex );
- }
-
- ScriptCode CFontMenuPopup::GetSelectedScript(void)
- {
- return ::FontToScript(mInstalledFonts[this->GetValue()-1]);
- }
-
- void CFontMenuPopup::SetMValue(ScriptCode theCode)
- {
- int i;
- MenuHandle menuH=this->GetMacMenuH();
-
- int maxItems=::CountMItems(menuH);
- for( i=0; i<maxItems; i++ )
- if( theCode == ::FontToScript( mInstalledFonts[i] ) )
- break;
-
- LStdPopupMenu::SetValue( i+1 );
- }
-
- void CFontMenuPopup::SetValueByFont(SInt16 theFont)
- {
- int i;
- MenuHandle menuH=this->GetMacMenuH();
-
- int maxItems=::CountMItems(menuH);
- for( i=0; i<maxItems; i++ )
- if( theFont == mInstalledFonts[i] )
- break;
-
- LStdPopupMenu::SetValue( i+1 );
- }
-
-
- // *********************************************************************************
- // • CUnicodeHubWindow
- // *********************************************************************************
-
-
- // ---------------------------------------------------------------------------------
- // • CreateUnicodeHubWindowStream
- // ---------------------------------------------------------------------------------
- CUnicodeHubWindow*
- CUnicodeHubWindow::CreateUnicodeHubWindowStream(LStream *inStream)
- {
- return( new CUnicodeHubWindow( inStream ) );
- }
-
- // ---------------------------------------------------------------------------------
- // • CUnicodeHubWindow
- // ---------------------------------------------------------------------------------
- void CUnicodeHubWindow::InitUnicodeHubWindow(void)
- {
- mFromUnicodeFlags=0;
- mToUnicodeFlags=0;
- }
-
-
- CUnicodeHubWindow::CUnicodeHubWindow(LStream *inStream) :
- LWindow( inStream )
- {
- InitUnicodeHubWindow();
- }
-
- CUnicodeHubWindow::CUnicodeHubWindow(
- const SWindowInfo &inWindowInfo) :
- LWindow( inWindowInfo )
- {
- InitUnicodeHubWindow();
- }
-
- CUnicodeHubWindow::CUnicodeHubWindow(
- ResIDT inWINDid,
- Uint32 inAttributes,
- LCommander *inSuperCommander) :
- LWindow( inWINDid, inAttributes, inSuperCommander )
- {
- InitUnicodeHubWindow();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ListenToMessage
- // ---------------------------------------------------------------------------------
-
- void
- CUnicodeHubWindow::ListenToMessage(
- MessageT inMessage,
- void *ioParam )
- {
- #pragma unused(ioParam)
-
- //Check if one of the check boxes was clicked on. If so, toggle the bits in the
- //appropriate control flag.
-
- //If the convert buttons are clicked on, the ConvertButtonHit method is called
-
- //If a popup menu is selected, we don't do anything about it
-
- if( inMessage >= kFirstFromUnicodeCheck && inMessage <= kLastFromUnicodeCheck )
- {
- mFromUnicodeFlags ^= ( 1L << (inMessage - kFirstFromUnicodeCheck) );
- }
- else if( inMessage >= kFirstToUnicodeCheck && inMessage <= kLastToUnicodeCheck )
- {
- mToUnicodeFlags ^= ( 1L << (inMessage - kFirstToUnicodeCheck) );
- }
- else if( inMessage == kLeftConvertButton || inMessage == kRightConvertButton )
- ConvertButtonHit( inMessage );
- else if( inMessage == kLeftDisplayHex || inMessage == kRightDisplayHex )
- ConvertTextToHex( inMessage );
- else if( inMessage == kFontMenuPopup )
- {
-
- CStyleText *fromText = (CStyleText*)FindPaneByID( kLeftText );
- CStyleText *toText = (CStyleText*)FindPaneByID( kRightText );
- CStyleText *targetText;
-
-
- Str31 fontName;
- CFontMenuPopup* scriptsPopup=((CFontMenuPopup*)FindPaneByID ( kFontMenuPopup ));
- ScriptCode theScript;
- TextStyle newStyle;
-
- theScript=scriptsPopup->GetSelectedScript();
- ::KeyScript( theScript );
-
-
- ::GetMenuItemText( scriptsPopup->GetMacMenuH(), scriptsPopup->GetValue(), fontName );
- ::GetFNum(fontName, &newStyle.tsFont ) ;
-
- newStyle.tsSize = ::GetScriptVariable( theScript, smScriptPrefFondSize );
-
- if( fromText->IsTarget() )
- targetText=fromText;
- else if( toText->IsTarget() )
- targetText=toText;
- else
- targetText=NULL;
-
- if( targetText )
- {
- targetText->FocusDraw();
- ::TESetStyle( doFont|doSize, &newStyle, true, targetText->GetMacTEH() );
- targetText->mCurKeyScript=theScript;
- ::SetScriptManagerVariable( smKeyScript, theScript );
- }
-
- }
-
- }
-
- void
- CUnicodeHubWindow::ConvertButtonHit( MessageT inMessage )
- {
- LTextEdit *fromText, *toText;
- LStdCheckBox *toCheckBox;
- UInt32 fromEncoding, toEncoding;
- Handle theTextToConvert;
- Handle theConvertedText;
- UInt32 sourceLen, inputRead, outputLen;
- OSStatus status;
- Str255 theString;
- ByteCount convertedTextLen;
- Boolean wantHexOutput;
-
-
- //Get the from and to text edit panel pointers as well as the value of the
- //from and to encoding panel popup item selected
- if ( inMessage == kLeftConvertButton )
- {
- fromText = (LTextEdit*)FindPaneByID ( kLeftText );
- toText = (LTextEdit*)FindPaneByID ( kRightText );
-
- toCheckBox = (LStdCheckBox*)FindPaneByID ( kRightDisplayHex );
-
- fromEncoding = ((CUnicodeTablesPopup*)FindPaneByID ( kLeftEncodingPopup ))->GetValue() - 1;
- toEncoding = ((CUnicodeTablesPopup*)FindPaneByID ( kRightEncodingPopup ))->GetValue() - 1;
-
- wantHexOutput = toCheckBox->GetValue();
- }
- else
- {
- toText = (LTextEdit*)FindPaneByID ( kLeftText );
- fromText = (LTextEdit*)FindPaneByID ( kRightText );
-
- toCheckBox = (LStdCheckBox*)FindPaneByID ( kLeftDisplayHex );
-
- toEncoding = ((CUnicodeTablesPopup*)FindPaneByID ( kLeftEncodingPopup ))->GetValue() - 1;
- fromEncoding = ((CUnicodeTablesPopup*)FindPaneByID ( kRightEncodingPopup ))->GetValue() - 1;
-
- wantHexOutput = toCheckBox->GetValue();
- }
-
- //Get the handle to the from text and its length
- theTextToConvert = fromText->GetTextHandle();
- sourceLen = ::GetHandleSize(theTextToConvert);
-
- TEStyleHandle theStyle=::TEGetStyleHandle( fromText->GetMacTEH() );
- TextEncodingRunHdl theRuns=0;
- ByteCount** theOffsets=0;
-
-
- /**********************************************************************************************************
- * TEC SPECIFIC CODE COMMENT
- *
- * I make my output buffers 3 times the size of the input buffers. The reason being is that I handle
- * every single encoding out there. There are some that require buffers larger than this depending on
- * the text that is being passed. You don't need to make buffers so large. You can always convert and
- * if you get kTECOutputBufferFullStatus, you need to increase you buffer size and continue the conversion
- * where it left of. The convert code in Convert.cp shows you this. However, by having such a large buffer
- * you should convert on the first try. Look specifically in CPPStarterApp::ConvertFromMulti.
- **********************************************************************************************************/
- #define SIZEOFOUTBUF 3L
- /**********************************************************************************************************
- * END TEC SPECIFIC CODE COMMENTED BLOCK
- **********************************************************************************************************/
-
- //Create the output handle to be at SIZEOFOUTBUF times the size of the source length
- theConvertedText = NewHandle( sourceLen * SIZEOFOUTBUF );
- FailNIL_(theConvertedText);
-
- //Call the convert function
- if( fromEncoding != 0 )
- {
- status = gTheApp->DoConvert( theTextToConvert, sourceLen, fromEncoding,
- theConvertedText, inputRead, outputLen, convertedTextLen, toEncoding,
- theRuns, mFromUnicodeFlags, mToUnicodeFlags, wantHexOutput );
-
- //If the output is a single encoding, then figure out if it is a mac encoding, if so, add a run with it.
- if( theRuns == 0 )
- {
- theRuns=(TextEncodingRunHdl)NewHandle(sizeof(TextEncodingRun) );
- if( theRuns )
- {
- ::HLock((Handle)theRuns);
- (**theRuns).textEncoding=gTheApp->mAvailableMappings[ toEncoding-1 ];
- (**theRuns).offset=0;
- }
- }
- }
- else
- {
- TextEncoding unicodeEncoding;
-
- //Make sure that the check box is set since the output that we are going to
- //get is in HEX
- toCheckBox->SetValue(1);
-
- gTheApp->ResolveConversionParams( NULL, NULL,
- toEncoding, &unicodeEncoding, NULL );
-
- if( gTheApp->IsUnicode( unicodeEncoding ) )
- status = gTheApp->ConvertFromMulti( unicodeEncoding, theTextToConvert, theStyle, sourceLen, theConvertedText,
- inputRead, outputLen, convertedTextLen, theOffsets, mToUnicodeFlags);
- else
- {
- ::ParamText("\pStyled Text can only be converter to Unicode", "\p", "\p", "\p");
- ::Alert(kSimpleAlert, NULL);
- outputLen=0;
- inputRead=0;
- convertedTextLen=0;
- status=paramErr;
- ::SetHandleSize(theConvertedText, 0);
- }
- }
-
- //Reset the handle size of the converted text to as many bytes as were able to be converted
- //and set the value of the toText LTextEdit to the converted string.
- ::SetHandleSize(theConvertedText, convertedTextLen);
- toText->SetTextHandle( theConvertedText );
- if( theRuns )
- {
- TEHandle toTextHdl=toText->GetMacTEH();
-
- ItemCount noItems=GetHandleSize((Handle)theRuns)/sizeof(TextEncodingRun);
-
- toText->FocusDraw();
-
- ::HLock( (Handle)theRuns );
- for(int i=0; i<noItems; i++)
- {
- TextStyle newStyle;
- ScriptCode theScript;
- UInt16 styleMode;
- OSStatus status2;
-
- /**********************************************************************************************************
- * TEC SPECIFIC CODE COMMENT
- *
- * After I use ConvertUnicodeToTextRun, I examine each of the encoding runs to determine what Font to use
- * in order to display the string. RevertTextEncodingToScriptInfo is used for this purpose. If it
- * returns a font name, then I use that one. When it does, it means that it picked up on an encoding
- * run that has symbol, dingbats, vt100, or an encoding from a font/text encoding variant. If it doesn't
- * return a font name, I just just the preferred App font for the script.
- **********************************************************************************************************/
-
- status2=RevertTextEncodingToScriptInfo( (*theRuns)[i].textEncoding, &theScript, NULL, theString );
- if( status2 == noErr )
- {
- if( *theString == 0 )
- newStyle.tsFont = ::GetScriptVariable( theScript, smScriptAppFond );
- else
- GetFNum( theString, &newStyle.tsFont);
- newStyle.tsSize = ::GetScriptVariable( theScript, smScriptPrefFondSize );
- styleMode=doFont|doSize;
- }
- else
- {
- theScript= ::GetScriptManagerVariable( smSysScript );
- newStyle.tsFont = ::GetScriptVariable( theScript, smScriptAppFond );
- newStyle.tsSize = ::GetScriptVariable( theScript, smScriptPrefFondSize );
- newStyle.tsFace = bold;
- styleMode=doFont|doSize|doFace;
- }
-
- ByteCount endOffset= (i==noItems-1) ? -1 : (*theRuns)[i+1].offset;
- ::TESetSelect((*theRuns)[i].offset, endOffset, toTextHdl);
- ::TESetStyle(styleMode, &newStyle, true, toTextHdl );
-
- /**********************************************************************************************************
- * END TEC SPECIFIC CODE COMMENTED BLOCK
- **********************************************************************************************************/
-
- }
-
- //Set the selection to the end of the text
- ::TESetSelect(-1, -1, toTextHdl);
-
- ::HUnlock( (Handle)theRuns );
- }
- else if( theOffsets )
- {
- TEHandle toTextHdl=toText->GetMacTEH();
- ItemCount noItems=GetHandleSize((Handle)theOffsets)/sizeof(ByteCount);
-
- toText->FocusDraw();
-
- ::HLock( (Handle)theOffsets );
- for(int i=0; i<noItems; i++)
- {
- TextStyle newStyle;
-
- newStyle.tsColor.green=0;
- newStyle.tsColor.red=(i%2)==1 ? 0xFFFFFFFF : 0;
- newStyle.tsColor.blue =(i%2)==0 ? 0xFFFFFFFF: 0;
-
-
- ByteCount endOffset= (i==noItems-1) ? -1 : (*theOffsets)[i+1];
- ::TESetSelect((*theOffsets)[i], endOffset, toTextHdl);
- ::TESetStyle( doColor, &newStyle, true, toTextHdl );
- }
- ::HUnlock( (Handle)theOffsets );
- ::DisposeHandle( (Handle)theOffsets );
-
- }
-
- //Dispose of our converted text handle
- ::DisposeHandle(theConvertedText);
-
- // convert inputRead to string
- ::NumToString(inputRead, theString);
- // display string in error pane
- SetDescriptorForPaneID( kInputReadCaption, theString);
-
- // convert outputLen to string
- ::NumToString(outputLen, theString);
- // display string in error pane
- SetDescriptorForPaneID( kOutputLenCaption, theString);
-
- // convert error to string
- if( status >= kUnicodeFirstError && status <= kIllegalHexString )
- BlockMove( UnicodeErrors[status-kUnicodeFirstError],theString, *(UnicodeErrors[status-kUnicodeFirstError])+1 );
- else
- ::NumToString(status, theString);
- // display string in error pane
- SetDescriptorForPaneID( kErrorCaption, theString);
-
- }
-
- void
- CUnicodeHubWindow::ConvertTextToHex( MessageT inMessage )
- {
- LTextEdit *fromText;
- UInt32 toValue;
- Handle theTextToConvert;
- Handle theConvertedText;
- ByteCount sourceLen,convertedTextLen;
- //OSStatus status;
- //Str255 theString;
- Boolean convertOK=true;
-
- //Get the from and to text edit panel pointers as well as the value of the
- //from and to encoding panel popup item selected
- if ( inMessage == kLeftDisplayHex )
- {
- fromText = (LTextEdit*)FindPaneByID ( kLeftText );
- toValue = ((LStdCheckBox*)FindPaneByID ( kLeftDisplayHex ))->GetValue();
- }
- else
- {
- fromText = (LTextEdit*)FindPaneByID ( kRightText );
- toValue = ((LStdCheckBox*)FindPaneByID ( kRightDisplayHex ))->GetValue();
- }
-
- //Get the handle to the from text and its length
- theTextToConvert = fromText->GetTextHandle();
- sourceLen = ::GetHandleSize(theTextToConvert);
-
- //Create the output handle to be at 3 times the size of the source length
- theConvertedText = NewHandle( sourceLen * 3L );
- FailNIL_(theConvertedText);
-
- ::HLock( theTextToConvert );
- ::HLock( theConvertedText );
-
- if( toValue )
- BufToHex( (StringPtr)*theTextToConvert, (StringPtr)*theConvertedText, sourceLen, convertedTextLen, 2 );
- else
- convertOK=FromHexToString( (StringPtr)*theTextToConvert, sourceLen, (StringPtr)*theConvertedText, convertedTextLen);
-
-
- ::HUnlock( theTextToConvert );
- ::HUnlock( theConvertedText );
-
- if( convertOK )
- {
- ::SetHandleSize(theConvertedText, convertedTextLen);
- fromText->SetTextHandle( theConvertedText );
- }
-
- //Dispose of our converted text handle
- ::DisposeHandle(theConvertedText);
- }
-
-
-
- // *********************************************************************************
- // • String To Hex and back Utilities
- // *********************************************************************************
-
-
- // ---------------------------------------------------------------------------------
- // • BufToHex
- // ---------------------------------------------------------------------------------
- void BufToHex( const unsigned char* src, unsigned char* dest, ByteCount srcLen, ByteCount &destLen, UInt8 clumpSize)
- {
- unsigned char *hex=(unsigned char*)"0123456789ABCDEF";
- UInt8 tempClumpSize = clumpSize;
-
- destLen=0;
- while(srcLen--)
- {
- *dest++ = *( hex + ((*src&0xF0)>>4) );
- *dest++ = *( hex + ( *src&0x0F ) );
- destLen+=2;
-
- if( clumpSize != 0 )
- {
- if( --tempClumpSize == 0 )
- {
- *dest++ = ' ';
- tempClumpSize = clumpSize;
- destLen++;
- }
- }
-
- src++;
- }
- }
-
- // ---------------------------------------------------------------------------------
- // • FromHexToString
- // ---------------------------------------------------------------------------------
-
- #define TOUPPER(c) ( (c>'Z') ? c & 0xDF : c )
- #define ISHEX(c) ( (c>='0' && c<='9') || ( c>='A' && c<='F') )
- #define HEXTONUM(c) ( (c>'9') ? c-'A'+10 : c-'0' )
-
- Boolean FromHexToString( unsigned char* str, ByteCount length, unsigned char* dest, ByteCount &actualLen)
- {
- unsigned char high, low;
-
- actualLen = 0;
-
- while( length )
- {
- //skip any empty spaces
- while( length && *str==' '){ str++; length--; }
- if(!length) break;
-
- low = 0; //initialize low to point to an impossible character
-
- //get the high byte
- high=TOUPPER(*str);
- length--;
- str++;
-
- //skip any empty spaces
- while( length && *str==' '){ str++; length--; }
- if(!length) break;
-
- //get the low byte
- low=TOUPPER(*str);
- length--;
- str++;
-
- //convert our hex number if possible
- if( ISHEX(high) && ISHEX(low) )
- {
- *dest++=(HEXTONUM(high)<<4) | HEXTONUM(low);
- actualLen++;
- }
- else
- return false;
- }
-
- return (low!=0); //if low==0 then we have an incomplete hex string
- }
-
-
- //----------------------------------
- // ---------------------------------------------------------------------------
- // • CStyleText
- // ---------------------------------------------------------------------------
- // Construct from input parameters
-
- CStyleText::CStyleText(
- const SPaneInfo &inPaneInfo,
- const SViewInfo &inViewInfo,
- Uint16 inTextAttributes,
- ResIDT inTextTraitsID)
- {
- LView(inPaneInfo, inViewInfo);
- mTextAttributes = inTextAttributes;
- InitStyleTextEdit(inTextTraitsID);
- AlignTextEditRects();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CreateStyleTextEditStream
- // ---------------------------------------------------------------------------------
- CStyleText*
- CStyleText::CreateStyleTextEditStream(LStream *inStream)
- {
- return( new CStyleText( inStream ) );
- }
-
- // ---------------------------------------------------------------------------
- // • CStyleText(LStream*)
- // ---------------------------------------------------------------------------
- // Contruct an TextEdit from the data in a Stream
-
- CStyleText::CStyleText(
- LStream *inStream)
- : LTextEdit(inStream)
- {
-
- Handle initialTextH = GetTextHandle();
- HandToHand( &initialTextH );
-
- ::TEDispose( mTextEditH );
- InitStyleTextEdit(mTextTraitsID);
- AlignTextEditRects();
-
- if (initialTextH != nil) {
- SetTextHandle(initialTextH);
- ::ReleaseResource(initialTextH);
- ::TESetSelect(0, 0, mTextEditH);
- }
- }
-
- // ---------------------------------------------------------------------------
- // • InitStyleTextEdit
- // ---------------------------------------------------------------------------
- // Initialize member variables of a TextEdit to default values - Also overrides
- // the parent's method and creates a styled text edit record as opposed to
- // a mono-styled text
-
- void
- CStyleText::InitStyleTextEdit(
- ResIDT inTextTraitsID)
- {
-
- Rect viewRect = {0, 0, 0, 0};
- mTextEditH = ::TEStyleNew(&viewRect, &viewRect); //<JAG>
-
- mCurKeyScript = ::GetScriptManagerVariable(smKeyScript);
-
- SetTextTraitsID(inTextTraitsID);
-
- // If word wrap is on, then the Image width is always the
- // same as the Frame width, which forces text to wrap to
- // the Frame.
-
- // If the Image width is zero (or negative), the user
- // probably forgot to set it. To accommodate this error,
- // we set the Image width to the Frame width. However, the
- // Image will not change if the Frame resizes.
-
- if ((mTextAttributes & textAttr_WordWrap) ||
- (mImageSize.width <= 0)) {
- mImageSize.width = mFrameSize.width;
- }
- }
-
- Boolean
- CStyleText::FocusDraw()
- {
-
- Boolean focused = LView::FocusDraw();
- if (focused) {
- StColorPenState::Normalize();
- }
-
- return focused;
- }
-
-
- // ---------------------------------------------------------------------------
- // SpendTime
- // ---------------------------------------------------------------------------
- // Here we make sure that the keyScript and the sysKeyScript are in sync
- // If they aren't we set the keyScript to be that of the sysKeyScript.
- // We don't do the later if there is a selection that goes accross multiple
- // runs
- void
- CStyleText::SpendTime(const EventRecord &inMacEvent)
- {
-
- LTextEdit::SpendTime( inMacEvent );
-
- if( mCurKeyScript != ::GetScriptManagerVariable(smKeyScript) )
- {
-
- UInt16 noStyles=1;
-
- if( (**mTextEditH).selStart != (**mTextEditH).selEnd )
- {
- StScrpHandle sTE=TEGetStyleScrapHandle(mTextEditH);
-
- noStyles=(**sTE).scrpNStyles;
-
- DisposeHandle((Handle)sTE);
- }
-
- if( noStyles == 1 )
- {
- mCurKeyScript = ::GetScriptManagerVariable(smKeyScript);
-
- CFontMenuPopup* fontMenuPopup=(CFontMenuPopup*)(GetDefaultView()->FindPaneByID ( kFontMenuPopup ));
- if( fontMenuPopup )
- fontMenuPopup->SetMValue( (ScriptCode) mCurKeyScript );
- }
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // ObeyCommand
- // ---------------------------------------------------------------------------
- // Here we handle Styled Text copy and paste which the original PP methods dont
- // handle or that have bus in them.
- Boolean
- CStyleText::ObeyCommand(
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
- Handle teScrap=TEScrapHandle();
-
- case cmd_Cut:
- ::ZeroScrap(); //Bug in powerplant. ZeroScrap should be called before TECut
- ::TECut(mTextEditH);
- ::TEToScrap();
- AdjustImageToText();
- UserChangedText();
- break;
-
- case cmd_Copy:
- ::ZeroScrap(); //Bug in powerplant. ZeroScrap should be called before TECopy
- ::TECopy(mTextEditH);
- ::TEToScrap();
- break;
-
- case cmd_Paste:
- ::TEFromScrap();
- ::TEStylePaste(mTextEditH);
- AdjustImageToText();
- UserChangedText();
- break;
-
-
- default:
- cmdHandled = LTextEdit::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- // ---------------------------------------------------------------------------
- // Click
- // ---------------------------------------------------------------------------
- // Here we make a font selection depending where in the text the user click.
- // We want our font menu to have the correct font displayed. If the click
- // yields a selection that spreads accross multiple style runs, then we
- // do not change the font selection. We should probably have a menu item
- // in the font menu that is blank to indicate to the user that there isn't
- // one possible selection to be made.
- void
- CStyleText::Click( SMouseDownEvent &inMouseDown)
- {
- LTextEdit::Click( inMouseDown );
- TextStyle theStyle;
-
-
- CFontMenuPopup* fontMenuPopup=(CFontMenuPopup*)(GetDefaultView()->FindPaneByID ( kFontMenuPopup ));
-
- SInt16 lineHeight;
- SInt16 ascend;
- UInt16 offset;
-
- UInt16 noStyles=1;
-
- if( (**mTextEditH).selStart != (**mTextEditH).selEnd )
- {
- StScrpHandle sTE=TEGetStyleScrapHandle(mTextEditH);
-
- noStyles=(**sTE).scrpNStyles;
-
- DisposeHandle((Handle)sTE);
- }
-
- if( noStyles == 1 )
- {
- offset=::TEGetOffset( inMouseDown.whereLocal, mTextEditH );
- ::TEGetStyle( offset, &theStyle, &lineHeight, &ascend, mTextEditH);
-
- if( theStyle.tsFont == applFont )
- theStyle.tsFont = GetAppFont();
- if( fontMenuPopup->mInstalledFonts[fontMenuPopup->GetValue()-1] != theStyle.tsFont )
- {
- fontMenuPopup->SetValueByFont( theStyle.tsFont );
- mCurKeyScript=::FontToScript(theStyle.tsFont);
- ::SetScriptManagerVariable(smKeyScript, mCurKeyScript);
-
- }
- }
- }
-
-
-
- // ---------------------------------------------------------------------------
- // BeTarget
- // ---------------------------------------------------------------------------
- // Here we make sure that the keyScript and the current font selected for the
- // text edit field being targeted is the same
- void
- CStyleText::BeTarget()
- {
- CFontMenuPopup* fontMenuPopup=(CFontMenuPopup*)(GetDefaultView()->FindPaneByID ( kFontMenuPopup ));
- if( fontMenuPopup )
- {
- ScriptCode theScript=(fontMenuPopup)->GetSelectedScript();
-
- if( theScript != mCurKeyScript )
- {
- fontMenuPopup->SetMValue( (ScriptCode) mCurKeyScript );
- }
- }
-
- LTextEdit::BeTarget();
- }
-