Apple Newton Utilities Guide de l'utilisateur Page 738

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 942
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 737
CHAPTER 20
Localizing Newton Applications
20-6 Using the Localization Features of the Newton
Measuring String Widths at Compile Time 20
When the size of a screen element depends on the size of associated text, you can
use the
MeasureString function to determine, at compile time, how big to make
the screen element. If you want to determine the size at runtime, use
StrFontWidth.
You could establish the width of the search message, for example, by using
MeasureString and LocObj together.
MeasureString(LocObj("What is your name?",
'find.nameQ), simpleFont12);
At compile time, the MeasureString call is replaced with a constant as long as
the arguments to
MeasureString are also constant. (LocObj produces a
constant result at compile time.) You could access the width at run time from the
view’s
ViewDrawScript method with this function:
func()
begin
local newBounds := deepClone(viewBounds);
newBounds.right := newBounds.left +
MeasureString("This is a string", simpleFont12);
SetValue(self, 'viewBounds, newBounds);
end
Determining Language at Run Time 20
You can determine the language at run time, and your program can use that
information to modify its behavior.
There are two ways to determine the current language:
Examine the active locale bundle. You can also add new locale bundles to give
the user new locale options and can set the locale from within your program.
The sections that follow discuss how to examine the active locale bundle.
Use the GetLanguageEnvironment function to nd out the native language
for which the ROMs on the Newton device are implemented.
Note that you need to decide which of these methods your application should use
in order to determine its behavior.
Examining the Active Locale Bundle 20
The global function GetLocale returns the active locale bundle, which is the
locale bundle that the Country pop-up is currently set to. Use this function rather
than accessing the frame directly.
Vue de la page 737
1 2 ... 733 734 735 736 737 738 739 740 741 742 743 ... 941 942

Commentaires sur ces manuels

Pas de commentaire