WWDC2001 Session 113
Transcript
Kind: captions
Language: en
hi buzu on Tracy I'd like to welcome you
to session 1 1 3 text on Mac os10
this session will focus on the
technologies that will enable a cover an
application to display text correctly on
Mac OS 10
when I say correctly I mean two things
first the text has to be in Unicode and
you need to support multilingual text
Mac OS 10 is an internal OS and you see
it Monday with avi we're going to be
shipping like you know a new version of
my question which support with Korean
Chinese and other languages in Europe
and your application needs to support
Unicode Unicode is like you know the
standard for encoding text now the
second point which is very important for
customers is you need to use quartz
rendering to display the text quartz is
a powerful 2d rendering engine but gives
to Mac OS test then it's special taste
with nice anti-aliasing on vertex with
drop shadows you need to use quartz to
render your texture you don't want your
text to stick like at the source term if
you still use the quick-draw rendering
excellent in this session we'll discuss
as well MLT which is the multilingual
text engine last year in this same room
i discussed MLG the benefits with
features and how it could be
implementing in your application we got
tremendous feedback from MLT and I'd
like to show you a couple of
applications that are using MLT and our
shipping actually some of them are
shipping right now or start with Acrobat
Reader we're very pleased Acrobat has
been using MLG for instance here you can
see in the find
window and Acrobat needed to support
Unicode and they had regular
implementation using TextEdit and NLT
fitted very well in this integration
towards Mac OS 10 with an LG they get
the cross Angela Singh and the Unicode
support they needed in there edit text
fields
another client of MLG and were very
happy but they're using it it's Maya
Maya is a huge application and when they
had to find a way to render her texture
in Mac OS Tina
they used an LT MNT was were choice here
a baguette for instance in the script
editor of a full emoji object with the
scroll bars the support Unicode text and
the text isn't areas correctly another
client and we're very pleased of that
because we think it's very important for
the platform is of course we sorcerer
I'm sure all of you know resource earn
here resource are implements MLT as a
you txt editor a lot of the strings are
going to be passing you know to the
parents manager for instance after the
Unicode well now with a new version of
restaurant thanks to MLG the
multilingual text angina you're going to
be able to have Unicode resources in
your application so you don't have to do
is here string and convert to text from
Mac OS encodings to Unicode and then
Pasadena to MLG draw theme text box or
over ap is another great feature but I
really like the new resource or is
actually the Unicode viewer they
implemented in resource server kind of
this window that shows you like you know
all the character set for Unicode with
65,000 characters so you could change
change without and you'd be able to see
other characters here in this case they
use Atsui or actually vertex and joiny
code text box api which enables them
once again to have the Unicode support
and the great quartz rendering last and
this is of course tech just a couple of
our customers the finder the finder uses
MLT the finder needs to be able to enter
Japanese and Roman text in the text
files when here in fact when you addict
texture in the finder in fact behind is
an MLT text object keycaps
you're no chica up ski caps is MLG as
well and uses with drafting text box
api's to display the characters on the
keys another great application of course
is word text which takes power of like a
mentee and shows by advanced typographic
features but we support on Mac OS 10
with that sweet apple type services
medical imaging
there are way more customers of course
and if you look at the carbon
development list you see a lot of
questions on MLT and a lot of developers
using it we're very pleased with what
we've been doing and with very pleased
with the feedback that you're giving us
so far
now the agenda for today I'll give you
quickly a brief overview about the text
architecture how the solutions we're
going to be talking about today are
going to be sitting in the Mac os10
overview and the Mac os10
architecture by itself then John Harvey
a senior architect on the MLT will be
talking about what API is you're going
to be able to use to display static
texture last year actually at the stem
conference we got a lot of feedback and
a lot of people are wanting to have a
Unicode text edit control they wanted
the toolbox to have like you know an MLG
control in the toolbox when I'm glad to
say with a new version of Mac OS 10 the
one but has shipped you know in March oh
you have actually this control and you
can use it John will be talking about
that as well thank you
we'll talk about that don't try and then
of course we still at MLG if you need
more control if you want like you know
support for drag and drop if you want
support for embedded objects we talked a
little bit about how you can do that
once again with the multilingual text
and shine and we have a special guest we
worked very closely with metrics and
happy to say that actually metros in the
next release will implement a couple of
new classes in power plant so in power
plant should be able to drag and drop an
object and you get all the images you
probably want either
Gregg Dao the architect for power plant
will be here and come on stage and show
you a demo of his implementation the
last point that we talked about is
rigged fabric one of Engineers on the
MLG team will talk about tips and tricks
on how to use a multilingual text em
China sometimes we get some questions
since you know architecture is different
between
quick geo textile and you know MLT and
he'll be answering a couple of like most
of the questions was the common
questions when we can ask them pretty
interesting I encourage you to stay
quickly the overview so we'll be talking
today about two different parts the
first thing you have to achieve in your
application is display some static text
and you know you can use
string it's not gonna work or draw text
it's not going to work because it's
going to work but then the text is maybe
winter with quick-draw and you don't
want that you don't want to use texture
to stick out you want it to use squats
and here we talk about solutions to draw
a static text using you know or
technologies that you squat and Unicode
the second part will talk about text
editing and here once again you'll have
two different choices you have we talked
about the single line control which is
what the tool box control talked about
that uses MLT and in order to display
bigger text areas and it once again if
you want support for embedded objects
like sound picture or movies then you'll
be able to use MLT all these
technologies use at Hsu atsui
is the heart or text rendering on Mac OS
10 at SU is Apple type services for
unicode imaging and it's report for
unicode layout engine but enables us to
enter CGI script Chinese Korean Japanese
and give us advantage of quads rendering
and lt of course uses that suite
directly and has its own implementation
using atsui on top of that you'll see
that you know that is by static text and
the single nine control the apparents
manager is the one that would be
actually using at Hsu and below all that
you see that quartz is the heart of a 2d
rendering and gives us a point of
flexibility of this new architecture to
render text on Mac OS 10 alright in
order to talk about these different
solutions to display text on Mac OS 10 I
have to invite on stage John Harvey John
Harvey has been working on MLT and is
the architect over technology hey John
[Applause]
well it's great to have a chance to come
out and talk to people about the things
we've been working on for the last year
and I appreciate your coming there we go
so the survey said I'm going to talk
about three different areas static text
drawing drawing a simple text area via
control the way you did it on system 9
with the edit text control it's exactly
the same kind of thing except you get
all the Mac OS 10 features with this new
control you
editing courts rendering automatic CJK
support and then finally we'll talk a
lot about building your own text area
using ml te it's not that complicated
but obviously there's more api's and so
on you need to be involved in then if
you just use the control okay so
displaying static text now there's
basically two approaches you can use on
ten you can use the theme text api's
which are really pretty nice because
they bring together all the parts you
need to deal with to get the right look
in your text you know it the theme text
API is they know about what is the
localization they know about what the
theme appearance should look like and
know about the state of whatever that
text is and then if you really want a
lot of control and like a incredibly
feature rich set of api's you'd want to
use that soui now in this session I'm
not going to talk anymore about atsui
rather than to say that there wasn't
drawing with that soui session they'll
be feedback for them but it's just
important to know that if you really
want to get down and have fine-tuned
text you those api's are available but
we'll talk about the theme text API is
for static text okay so here's the set
it's a pretty small set obviously the
first thing you want to do is render
text for that there's draw theme text
box it's basically the same kind of
functionality you got from the text edit
text box but you get your courts
rendering which you can see we're gonna
emphasize over and over again how
important that is to have and so I mean
that's other than that you get your
justification right center left the
standard things and I'll talk a little
bit about the parameters that get passed
into this that give you the more
features more control over how the text
looks or what the fun is
if you want to measure that text which
obviously a lot of times you want to do
you want to figure out how big the box
is that you're gonna draw into you can
call the get theme dimensions this
returns not only the height and width of
text but it will also return a baseline
which typically is a small negative
value one or two and you add that to the
height to figure exactly where to start
your drawing and unten since a lot of
things are shadowed you need to find out
like how much shadow space there's gonna
be around your text so you don't clip
that out or draw over it and that second
API text shadow offset will tell you
that it's a rectangle with offset values
as the return okay and finally I think a
nice thing is to truncate theme text on
nine you used to have to call I I think
it's a text utility function to get a
truncated string back and then you'd
have to go to quick draw to render it
truncate theme text will do the
rendering for you and you know these
replace these old familiar routines and
I think a really nice thing is you don't
have to sometimes look in the in
TextEdit sometimes looking quick draws
sometimes looking text utilities they're
all there an appearance manager
specifically appearance dot H it's the
header where you can find them okay so
talk a minute about the parameters that
you pass into this there you have the
concept of meta fun IDs these have been
around for a while in the appearance
manager but they give you some really
nice control it makes it easy for you to
tell what you want the text to look like
without having to do all the work you
had to do online where you'd have to go
looking script manager data structures
and things like that to find what the
right text is you use these api's utaite
you say okay I want the views font the
push-button push-button font something
like that the appearance manager does
all the work what's the localization
what's
shadowing that kind of thing at the same
time if you do want to use a font of the
port there's a metaphor that says use
the information in the poor and by using
these meta fonts you don't have to say a
fine a style size explicitly it figures
that out and again if you wanted to use
the information in the graph port you
use the the meta font which says use
font or port information like I said
these will take care of proprietary
effects you know if something's active
inactive that kind of thing on the
desktop John and why you know the doc
kind of tax that thing those things and
this these are Unicode savvy that the
eunuch eight one way that they are
Unicode savvy is when you pass text into
these api's use a CF string wrap that's
really the way to package Unicode text
on Mac os10
the toolbox deals completely in there's
and it's an opaque structure you're
probably familiar with it and it will
efficiently store Unicode text in there
you just pass it into the end of these
functions or other window tiling menu
functions and it will draw the text in
there
okay so making sure these perform at
their best there's a few things you can
do these a where appropriate these api's
take a cg context ref now if you are
allowed to pass null in if you do the
function will create a cg context ref
and then dispose it obviously that takes
time sometime not a huge amount of time
but if you're calling the function over
and over again it's creating going away
creating thrown away its time wasted so
you can create your own keep it around
and just use that to pass in there's
like anything you cared you know be
careful how often you measure tax catch
the values you get from measuring
attacks and so on don't like constantly
be calling the measurement routine
the time there's a lot more that goes on
on 10 you know probably on nine it was
really easy to just get you know text
width all the time that was real fast
compared to maybe storing it but it's
really it's important to think about
holding on to those values and then of
course in the engineering group
performances you know our utmost concern
and so we're working on speeding things
up internally okay so next area I'll
talk a bit about the edit text control
which you know for your basic editing
needs passwords so on is there it's real
easy to use whoops
keep pointing up with that okay so again
you use this you get courts rendering
for free you don't need to worry about
creating the cg context in this case the
control does that for you the one thing
that's nice is you use the same control
and you'll get building support for CJK
input but really there's a lot a now a
Mac os10 that has input methods I mean
there's unique area to input methods hex
input methods things like that you just
use this control that's all build in
that's different from 909 you had to use
be sure and you use a different proc
idea if you wanted to care about that
I'm probably diddle around a little bit
with TSM te and modified dialogue
structures and things like that but this
is you don't need to think about it it's
just there which of course is really
important on an international system
again you know this controls build on
top of MLT that's different from the
edit text control which was built on top
of TextEdit but it's the same concept
you know the basic text engine and then
the control on top of that if you want
to create this control well all the
controls on 10 now have a create
function which is a bit more
straightforward to use there are only on
10 so the old ways of course still work
new control get new control
and in that case we have the new croc ID
which is K control edit Unicode text
pack
okay so with that we'll move on to the
building you're in text area using M LTE
directly so we've you know last year we
talked about some of these features but
we want to go over them again people may
not have been here people not you know a
lot of new developers coming over to Mac
I think because of system 10 again it's
this is uncarbonated it Unicode text
this is what you use M LTE there's no
more 32k limit that's been said a lot of
times it was was a big problem in the
past with TextEdit for years and years
people said fix that fix that well we
didn't fix it in TextEdit we made a new
engine and again you get your building
support for CJK you don't have to worry
about it and it's really not right as I
said to just say building support for
CJK it's building support for input
methods and there can be an input method
for any language now any section of the
unicode character set in the old days
you had to allocate and hook your scroll
bars up with TextEdit and handle the
scrolling there you don't have to do
that that's build in really everything
is handled drag and drop and any sort of
click handling that you had to deal with
a lot of code in the past well not a lot
but it's significant amount let's just
handle with one function the TXN click
function we support embedded objects
pictures sound movies there's a single
tab for document and we have a multiple
undo redo stack and also a way to find
out what the undo redo action is so you
can then not only just say undo read
but undo typing undo cuts and that kind
of thing and you know again in a game we
were to say this you can you get the
courts rendering which is such a
signature part of Mac os10 okay so quick
comparison you know I talked about how
and TextEdit you had to do work to
scroll and print and things like that so
in TextEdit you had to write code create
the scroll bars hook the rectangles out
deal with offsetting the rack there
certainly was a te click function but if
you were scrolling there was more you
had the more that you had to do than
just call te click all that scrolling is
handled with the TXN click there's one
thing you know it's the multilingual
text engine but for historical reasons
the api's begin with the signature TX
and so it's building building support
for clicks that includes drag and drop
and all the highlighting and the other
big thing is if you want to print text
edit you have the right fairly large
amount of code and that's just you
there's two functions txm page setup and
TX and print you can call and you get
the printing so just to emphasize this
you can see the difference in lines
these it's 269 line these are this
samples are taken from the te sample
which has been shipping with all the
development environments that ever went
amateur works in PW there's 269 lines to
do these things and it compared to two
if you do it in ml te and on the web
there's a piece there's a project a
metro works project which has the old te
sample and then a new ml te sample built
in the same project and you can compare
the files you can see it's the same
basic functionality and it's just a lot
of care dropped out of the MLT
version the nice thing is you know I
mean you need this functionality but you
really probably rather not worry about
it because you're trying to give
something else to your users your
clients so you don't have to anymore
okay now something I'm really looking
forward to because I haven't seen it yet
we're gonna see the demo from Greg Dale
and I think this is gonna be really
great
[Applause]
okay hi
I'm gonna quickly just run through a
couple slides here I think John already
mentioned everything that M LTE and
Atsui and theme texture line can do and
what I've done is created some
powerplant classes that wrap all this
functionality up into simple neat
packages that you can use directly in
power plant so I have a class now for M
LTE it replaces the existing TextEdit
classes there's also a class that calls
L theme textbox to give you just a
simple static text caption that you can
use instead of all the other power plant
caption or static text controls let me
just move quickly to the demo here this
machine's seven
come up I have a project here that I've
built with these new classes I'm just
gonna run it quickly first thing that
comes up is we have an EM LTE pane pane
here I can type text here I can also
here I have in the finder I've just made
a couple of a picture of clippings I can
take that drop that in there now I have
you know light bulb in there can clip
back out another one in car in there so
it supports automatically graphics and
text mixed together again em LTE is
giving me the scroll bars automatically
it's giving me the font menu
automatically it builds the font menu
for me I can select the font in there
something more readable bigger capitals
there different font it also
automatically supports Unicode here I'm
gonna switch over to a Japanese keyboard
here and if I type some there I get to
automatically get Japanese characters
right mixed in with the same English
characters pictures everything is all
wrapped together neatly for me by M LTE
undo/redo here I can undo what I did
there
and do a little more keep going on the
undo here I'm under undoing the picture
drop and then I can go back redo
everything and all this is handled
automatically by M LTE what I did is I
took the existing power plant L edit
text classes pretty much stripped out
all the code in each of the functions
and replace it with one or two lines of
text of calls to M LTE
so in terms of your users your code that
uses power plant it'll be almost exactly
the same the same API you'll be just
calling into a different object but your
calls will be all be the same and it'll
just work much better and faster make
that up here so quickly
here's a demonstration of the theme box
theme text box control or actually not
to control just a pain one of the
problems with this is a normal static
text control people have mentions that
it automatically erases so here you can
see that there's a the grey stripe
background behind the text when I have
it over a picture if you don't want that
to happen you can use the new theme text
box class which will just draw the text
directly without any erasing let's see
if I click off if there the text
automatically dims there comes back and
that's all taken care of automatically
and this is all properly anti-aliased
here over the picture and finally I just
want to show quickly here Atsui although
John didn't mention a lot of the details
of what you can do with it here isn't a
sample here of the animation I'm doing
myself just quickly inside a loop what
I'm doing is I'm changing the degree of
rotation by five degrees each time and
then just redrawing and here I'm drawing
over a background picture
and all that Suey is handling everything
for me so this very flexible text you
can set you know the rotation you can
set the size the style and all sorts of
other features and all that is wrapped
together in a few in the two powerplant
classes one for handling the text layout
itself and the other for handling the
absoutely style and you can take those
classes and use them in a custom pain to
draw captions like me doing a graph or
something like that we need vertical
text on an axis all this is accessible
here from just a couple calls to
absolutely classes and best of all this
is also integrated now into constructor
quickly here you can here's the MLT e
pain that I had up there I can double
click here all the options for ml te are
accessible to you here from the
properties it can change the file type
that's associated with the ml te the
encoding here's some options you
probably can't read maybe all the
options here but I can turn off whether
it has scroll bars whether the carrot
blinks in the background or not we
shrink this one up hearings take this
here and maybe shrink that a bit and go
back here to layout catalog and drag out
a new ml te pane here so I can put a new
one right next to that one there and if
I save this
then go back to my project run you'll
just bring in the new PPO B and here I
have text over here text over here so
again it's very simple to use you just
use it like you do any other power plant
paint again the same thing for the theme
text
theme text window for the theme text box
again I have a couple new options it
supports the theme font ID so here I've
chosen to use the current port fund I
can switch over to use the system font
you won't see it updated in constructors
and constructor hasn't been rebuilt yet
with the new classes and maybe I'll turn
off I don't want it to dim when inactive
I can save this again go back to my
project and run that again through bring
up the theme text and now you can see
the theme text box is again drawn in the
system font again using the theme font
ID so you don't have to worry when your
internationalizing your code whether
it's Japanese Korean and English or
whatever you'll get the proper system
font without worrying about having to
set up in power plant now where you have
to make a text traits resource when you
put the name of the font in there here
you can choose the theme font ID and
again if I click here you can see there
the text doesn't dim I've turned that
off so you have the option of having the
text dim or not in the background
depending on your needs so this is all
built in the power plant unfortunately
it's not in the version you have on your
CD now that version froze about a month
ago and it didn't have time to update it
but it'll be in the next seed version of
power plant which if you haven't signed
up already you should consider joining
the Metalworks beta program and you can
come by the booth and ask about this or
check on the website and it'll give you
directions for sending an email in to
join up on the beta program and that way
you'll be able to get access to the
latest builds of power plant and these
new text features ok
[Applause]
well that that's really great I'm so
rewarding to work on something and you
wonder how much people use it while
you're work on it and then to see that
demo is fantastic for me and I'm really
thanks to Greg for doing that I can't
wait to start using it myself make my
life a lot easier okay so now we'll talk
a little bit about the newer things
we'll talk about quartz rendering again
and so quartz rendering you know over
and over again this is what you can get
you get your anti-aliasing it's really
significant part of the look of Mac OS
10 also in M LTE we have the beginning
of support for Carbon events we're going
to extend this as we go along right now
we support text input Carbon events and
I'll talk about some of what this gives
you in the on system 9 all the input
from Unicare keyboards came through
Apple events currently on the 10 now it
by default comes through Apple events
but you can tell us to use carbon events
or you can put your own text input
handler on top of us and do filtering
which I'll talk about then the other
thing we've we've done is where propria
we haven't changed our api's but
underneath under the hood we've adopted
the newer Mac OS 10 architecture
specific cases are printing and the
scrap manager so we use the promises
things like that if you're familiar with
the new Mac OS 10 scrap manager
ok so quartz rendering let's look at how
you do this you get your system get that
write system look when you do it and
it's really pretty simple to do you
create a CG context and then you hook
the CG context up with your ml te object
that's all you need to do you can show
you the code right here so
there's a few data structures you have
your TX n the preface data structures
the controlled tag and the controlled
demonsaw data the tag you set with a
constants it's actually defined in
at-ats unicode that age that's the etsu
e header the other ones are in mac text
editor dot h that's where ml te
constants and functions are defined and
then you create your cg context with the
create cg context report that's an api
in quick draw it once that's done and
it's done successfully you plug that
into the control data the value field
and then you just simply call this TX n
set TX and object control once you've
done that you get courts rendering you
don't have to do anything else okay the
next thing is the carbon events text
input specifically it's nice you know to
see everything and then it highlight
like that okay so we support all the
text input events so that includes the
text input event when it's coming
directly from a keyboard and then the
text input events that come from an
input method which include all the ones
which tell me which the input method
might ask where the text is or might ask
for the text and that kind of thing the
nice thing about text input events which
for you which was very very hard to do
if close to impossible when we used
Apple events is you can P pre and post
process text input and the other thing
to know is that if if you tell em LTE to
use text input events that's going to be
the optimal path because right now on 10
if we are still using Apple events what
happens is the text services manager has
to take the text input event off the
event view pull the data out allocate a
Apple event fill that in and then pass
that to us I mean it's not something
that's so time-consuming that you really
and you're typing but if you if you tell
ml to e to use the text input and event
handler that doesn't happen the data
structure can just move around s is
without any massaging on the part of the
text services manager okay so how to do
this just see this is the card is
actually very very similar to what we
saw for the cg context graph you've got
those same TX and Control old data
structures this time we use a constant
used carbon events which is in the Mac
text editor header and and we have a an
array of keys and array of values which
we'll use to build a CF dictionary we
use CF dictionary so we can include more
and more carbon events s it's
appropriate
so the expandability is right there and
ready for you or us ready for everyone
okay then there's a data structure the
TXN Carbon event info a few field you
set up there you say I'm using carbon
events today obviously you can turn them
off if you want by setting that to false
in this case there's a flag that says I
want you to turn off the Apple event
handlers this is usually what you want
to do but the thing is that you'll when
you throw this object away
if you have other ticks and objects or
there might be other ticks and objects
around in your application you want to
be sure and tell it to turn the Apple
event handlers back on then you create
your dictionary with CF dictionary
create one of the core foundation
functions and at that point you put a
pointer to the carbon event info in the
value field and you call that same
function again it hooks it up and M LTE
will start using tech handling text
input with a carbon event handler rather
than Apple events and in this case you
need to be sure and release the CF
dictionary because all the information
ml te needs is copied when you call the
set ticks and object control
very straightforward is sort of like
boilerplate now for telling ml te what
to do on tan okay so there's the three
topics again and what I mean I'm not
going to say anything else there's new
slides talking about the printing or the
scrap managers just as I said before we
have the exact same functions that we
had before you know txm pays copy cut TX
and print Tex and page setup but
underneath they use the new
architectures okay so at this point I've
been working a lot with Rick Fabrique
he's done most of the work or all the
work or not all the work but muscles
work on carbon live and he's had the
most interaction with you the developers
and he'll talk about some problems
people have had and issues that they
weren't sure about that he's been able
to help them with and basically his
experience working with developers
thanks a lot thanks John in working with
developers who are integrating ml te
into their applications we get many
questions as Jonah said similar to
what's the best way to program for this
particular task so what we're gonna do
now is go over some of the tests that we
have received the most questions on what
you see here is a list of the tests that
we'll be discussing today and will see
this list several more times as we go
through each of the tasks individually
we're going to be starting with what is
the best way for you to change the size
of your text objects and there are some
key concepts to understand in order to
get the best interaction between the
user and your text object as well as the
printout that you're looking for when
you print the object out now the first
thing to understand is what the
difference is between the view rectangle
and the destination rectangle and how ml
te defines them so the destination
rectangle defines where the text will
wrap in your text objects it's the full
page of text for your object
is what would be printed out when you
print the object out the V rectangle
shows the currently visible portion of
the destination rectangle and is what
the user sees at any one time now in M
LTE the view rectangle includes the area
taken up by the scroll bar so if you're
familiar with the Mac OS as original
text engine the V rectangle in TextEdit
objects doesn't include these the area
of the scroll bars and that's because
TextEdit objects don't have scroll bars
if scroll bars were necessary then the
developer would have to create and
manage them separately from the text
object but since them LTE handles the
creation and event handling
automatically for you we do include the
areas from the scroll bars so the
initial value of these rectangles are
set when you create the object with txon
new object and this abya api has a
parameter that accepts either null or a
pointer to a rectangle if you passed in
null to this API what you would get back
is an object that takes up the entire
window basically the view rectangle
would be the bounds of the window and
the destination rectangle would be set
to the standard u.s. letter page size if
on the other hand you passed in a
pointer to a rectangle the object that
you got back would only take up a
portion of the window and that course
would be equal to the rectangle that you
passed in now in this case the
destination rectangle would be that
rectangle but we don't include the the
scroll bars in this case because you
want the text to wrap at the scroll bar
and not go underneath so let's say you
need to change the size of your object
if you had passed a null and your object
takes up the entire window then what you
should be calling when the user is
trying to change the size of the window
is txon grow window and what this will
do this API changes both the size of the
window and the view rectangle for your
object but if you have passed in the
pointer to a rectangle you would want to
call one of these API so let's say you
have an object that you allow the user
to change the size of and when the size
of the object changes you want the text
to always wrap at the scroll bar in this
case
would call the first API here txon
resize frame passing in the new width
and height of your your object what this
API does is it keeps the destination
rectangle and the view rectangle in sync
so that the text will always wrap at the
scroll bar now let's say you have
another object that when the user
changes its size you don't want to
change the size of the the text the the
destination rectangle on your object
just the view into it in this case you
would call the second API here TX and
set frame bounds in this case you would
be passing in all four boundaries of the
new view rectangle now this API is very
handy if your object takes up the entire
window because what it does is well
actually I'm not I'm not there yet so
what this API will do is it's also
helpful when you want to move the object
around in your window because you are
passing in all four boundaries so we
don't offer an API that allows you to
change just the destination rectangle
but if you find it necessary to change
the dimensions of the destination
rectangle what you can do is call txon
resize frame passing in the new width
and height of the destination rectangle
and what this will do is the side effect
will be that the viewer rectangle will
also change so then you could call after
that txon set frame bounds so that you
can reset the the frame of the view
rectangle back to what you wanted it to
be so we do offer a couple of options
that allow you to change the behavior of
these api and they deal with how the
text will wrap in your objects the first
option here always wrap it view edge if
you go back to the example of your
object where you always want the text
wrap the edge what you could do is pass
in this mask to TX some new object and
you create the object and what this
option will do was it will keep the
destination rectangle always in sync
with the V rectangle regardless of which
of the API you call so what I was going
to say before is if you have a window
that the object takes up the entire
Tiwa no the you're gonna have to call
Jackson grow window and normally this
API only changes the size of the view
rectangle but if this option is set then
the destination rectangle will be kept
in sync with the V rectangle and text
will always wrap in your window so if
you have an object that you allow the
user to edit source code you're going to
want to turn word wrap off so our second
option here allows you to do so what you
would do is you would pass in the word
wrap state tag to the API TX and set TX
and object controls and what that does
is basically sets the the width of the
destination rectangle to be infinite so
text will not wrap unless the user
explicitly enters a character that ends
a line and one example would be
character turn so along with the tag
what you would want to pass in is a
constant that is defined in Mac text
editor dot H telling the object whether
it should be turning word wrap on or off
so we offer several API that lets you
change the size of your objects and that
gives you the flexibility of getting the
exact behavior that you want and you can
have different types of objects
so another task that we've gotten lots
of questions on is how to set the style
of a certain certain range of text in
your object and in order to do that what
you need a call is txon set type
attributes what you would do is you
would fill in an array of txon type
attributes with all of the attributes
that you want to change and then pass
that array into the API along with a
count of the number of attributes are
changing what I want you to note here is
that you can change as many of the
attributes as you want with a single
call to the API just simply by filling
in as many of the elements of the array
that you need now along with the array
and the count you would also be passing
in the start and end offsets for the
text you want updated so in this case
when this text gets executed the current
selection will become read it will have
a font size of 36 and it will become
bold pretty straightforward
filtering text that's another important
thing that we had questions on and so
for instance you may have an ml to e
field that you only want numbers to be
entered into or you want to filter out
characters like the carriage return or
tab character what you would need to do
is install some filters and in this case
four key events entered from the
keyboard
these filters take the form of carbon
event handlers here's an example of one
of them normally what you would do is
you would install this this miss handler
to the particular class the event class
of text input and the event kind of
Unicode for key event so you want to be
doing the test for those values here in
your filter but I put them here so you
can see what their values are this
example here basically just makes sure
that all the the key downs in your
object are numbers if they're not
numbers then they're filtered out so you
do your test if you you you want the
text to be entered into your object then
what you would do is you would return
event not handle they're telling the
carbon event manager that you haven't
handled the event so pass it on to some
other handle that may
in this case that would be ml 2e if you
do want to filter the text out then you
would return no error telling the carbon
event manager that you you've handled
the event with no error and nothing else
needs to happen so this event handler
for Unicode for key event will get
called for every key event that's
entered into the keyboard if there isn't
an input method handling the text if you
do have an active inline area however a
second handler will be called and this
is the update active input area what you
would do here is basically the same
thing but you would need to wait until
the active input area has been confirmed
and there's a piece of information in
the event that you can examine the tail
when this happens when this does happen
then all you need to do is do your test
on all of the text that was just entered
and part of the data for the event is
the range offset so you know exactly
what text to filter and you return the
same values depending on whether you
want to filter that data in the filter
that data out or let it pass in now
normally you want to have two separate
filters you'd have a single one and you
could install it directly to the two
event kinds update active input area and
Unicode for key event I have two filters
here so that I can fit them on a slide
on two slides
okay so entering I data in from the
keyboard is one way to get text into
your object but you can also have drag
events happening so to be able to filter
that data you would need to install your
own drag handlers and it's pretty easy
to do the first thing you need to do is
tell MLT not to install its drag
handlers and then basically you just
install your drag tracking and drag
receive handlers and I'll describe those
two handlers in a second telling ml to
eat nuts to install its drag handlers is
really easy all you do is when you're
creating your object you pass in do not
install drag procs mask to TX a new
object now this method doesn't disable
drag and drop dragging from your object
is still enabled at this point all it
does is it temporarily disables drags to
your object until you've installed your
drag handlers so the first drag handler
you need to install is the direct
tracking procedure and this handler gets
called continuously as you drag as the
user is dragging the data over your
object and mLT's default behavior is
isn't sufficient in most cases so all
you would need to do is pass this event
on to 2m LTE by calling GX and drag
tracker in my example here I'm doing
some eye candy just to show you that if
you need to do something you can but as
I said mLT's default behavior is in most
cases sufficient now the filtering of
the data is done here in your drag
receive procedure and this gets called
once when the user lets go of the mouse
button and has dropped the data into
your object this example here also
filters out anything that isn't a number
so the first thing you need to do is
test the data to see if it's all digits
all numbers if so then you want to pass
the event on to ml to e by calling TX
and drag receiver if you do want to
filter the text out however you pass no
error return no error telling the drag
manager that you've handled the event
with no error and nothing else needs to
happen sorry
so I've given you some help on some of
the tests that we've been getting
questions from from you guys if you have
any more questions and I'm sure you do
please stay for the Q&A session at the
end of this session and let us have it
at this time I'd like to bring exhibit a
back up to go over a quick summary of
what we've been talking about today
[Applause]
all right a quick wrap-up for this
session so once again you don't want
your application to stick out like a
sore thumb by displaying text with
creature text and you want your
customers to be able to enter Unicode
text and use all the power of Atsui and
the quads rendering once again all these
technologies we've been talking about
today
use the power of that suite for doing
the Unicode rendering and use the power
of quad talk to the bleed the text
correctly with the right hand see a
thing
so in order to display text on the Mac
os10
please use VirtualBox api's the theme
text box api's are great
we're still working of course and always
making them better they are like a nice
migration for you to display text static
text correctly if you want to have like
editable text areas you have two
solutions if you want like you know a
quick turnaround and let's say you're
using already you know the alt text edit
control please use the new Unicode edit
text control John talked about how you
can use that it's very straightforward
it could be just a matter of like you
know using the new Pro Qaeda for a
Unicode text control if you need more
controller and as we said if you need
embedded objects if you need support for
like you know sound movies and pictures
in the object if you want to like
control yourself the scroll bars if you
want vertical horizontal if you want
drag and drop please use the MNC ApS
directly I think we show you that you
know the set of API that we're giving
you is very powerful in just a couple of
course you'll be able to achieve a lot
you get not only the support for
multilingual text which would get as
well all these features that have been
missing in text edit as you're saying to
with power plant if you're using power
plant you get all these features very
quickly integrated in your application
which gonna make your life way way
easier I'd like to give you some
information on the where you can get
actual information on or documentation
we just released the MLT documentation
which has been updated tech pubs has
been doing like a fabulous job without
technologies in the last year releasing
more and more information
I'm glad to say that actually we be able
to get the PDF on the web or you can
actually get the bond documentation from
fat brain you have here like you know
but - it's the two places on the web
where you can get them we have a lot of
simple code that uses the multilingual
text I'm China and you'd be able likely
to find the letters simple cannot the
carbon nib SDK we have as well and the
mentee SDK but the carbon leave as DK is
great because we updated every time with
your new release for carbon Lib so
you'll get there like you know the
letters things would get like actually
the application that was written just to
show you the migration between text ly
to Amenti is kind of nice
atsui is the center of text rendering
and that's like you know the foundation
for all your text drawing once again as
John said you need more control and
going out you really need to measure
over text yourself and you need let's
say you're writing your own text engine
then please check out let's we
documentation and here you are which
you'll find it on the report apple.com
so where to go from here we didn't talk
about Kokua text but for a very good
reason which is Kokua text is already
ready for Unicode and support squads as
well if you need more information about
using text where next text view classes
for instance in Cocoa please go to the
session 122 on Thursday which will be
actually in this whole front management
it's a big big big new thing here on Mac
OS 10 with like all these new phones but
we support now I encourage you if you
need to have more information on that to
go to session 128 Thursday at 2:00 in
room C I'll be there we talked about the
Quattroporte and if you need more
information about how do I get you know
my cg contacts on my graph port how can
I manipulate do rotation skewing
rotation and all these new things that
are supported by the quartz rendering
engine
this goes to session 132 graphics and
imaging tips and tricks in room Hey - on
Friday at 9:00 a.m. if you have feedback
and I'm sure you have and you want to
let us know that you know we're on the
right track you love what we're doing or
even if you have questions so you want
to tell us hey I need this API please
come to the International feedback forum
it's a great way for us to measure you
know what we're doing how much like you
know these answers you need and it's a
great way as well to talk to developers
another great way to talk to our
engineers is to come to more of what we
could international lunch where French
food would be served in the cafeteria
actually and we'll have we'll try to get
some balloons and you know we'll have
different themes going on we have like a
table or if you want to talk about the
fault management api's we'll have a
table about text and we'd get you know
cocoa engineers as well there so if you
have you know cocoa and carbon question
on the same table you'll be able to like
you know get your answers we'll have
another table two on localization and
there is a session that is not very but
you'll have a session on localization
and how you can localize your
application for Mac os10 to more
Thursday in room C at 3:30 should you
have any questions you can always
contact me exactly the type elle.com I
work in worldwide developer relations
and that's my job to answer you need and
to make sure that the api's that you
want and the bugs you want to be fixed
are fixed so you can always contact me
it's great I have a lot of developers
already contacted me and have been
working very closely with let probably
some of you here don't hesitate to to
send an email
you