145 lines
15 KiB
HTML
145 lines
15 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Interface Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheInterfaceKit_Overview.html" title="The Interface Kit" /><link rel="prev" href="BTextControl_Overview.html" title="BTextControl" /><link rel="next" href="BView_Overview.html" title="BView" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BTextControl_Overview.html" title="BTextControl"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BView_Overview.html" title="BView"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Interface Kit</div></div><div id="headerB">Prev: <a href="BTextControl_Overview.html">BTextControl</a> Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a> Next: <a href="BView_Overview.html">BView</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BTextView_Overview"></a>BTextView</h2></div></div></div><a id="id559742" class="indexterm"></a><p>
|
||
A <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
object displays text on-screen, and provides these text
|
||
manipulating features:
|
||
</p><ul class="itemizedlist"><li><p>
|
||
It lets the user enter, select, and edit text from the keyboard and
|
||
mouse.
|
||
</p></li><li><p>
|
||
It supports standard Cut, Copy, Paste, Delete, and Select All editing
|
||
commands
|
||
</p></li><li><p>
|
||
It provides an Undo mechanism.
|
||
</p></li></ul><p>
|
||
By default, a <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
displays all its text in a single font and color. The
|
||
<a class="link" href="BTextView.html#BTextView_SetStylable" title="SetStylable(), IsStylable()"><code class="methodname">SetStylable()</code></a>
|
||
turns on support for multiple character formats.
|
||
</p><p>
|
||
Paragraph formats—such as alignment and tab widths—are
|
||
uniform for all text the BTextView displays. These properties can be set,
|
||
but the setting always applies to the entire text.
|
||
</p><div class="admonition warning"><div class="title">Warning</div><div class="graphic"><img class="icon" alt="Warning" width="32" src="./images/admonitions/Stop_32.png" /><div class="text"><p>The <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
class isn't multi-thread safe; don't issue
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
calls on a <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
object from multiple threads, or you may see unusual
|
||
behavior; in general, only the thread that created the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
should issue calls on it.</p></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BTextView_Overview_Offsets"></a>Offsets</h3></div></div></div><p>
|
||
The <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
locates particular characters in its text buffer by offsets
|
||
from the beginning of the data. The offsets count bytes, not characters,
|
||
and begin at 0. A single character is identified by the offset of the
|
||
first byte of the character. A group of characters—the current
|
||
selection, for example—is delimited by the offsets that bound its
|
||
first and last characters; all characters beginning with the first offset
|
||
up to, but not including, the last offset are part of the group.
|
||
</p><p>
|
||
For example, suppose the <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
contains the following text in Unicode UTF-8 encoding,
|
||
</p><pre class="screen">
|
||
The BeOS(TM) is . . .
|
||
</pre><p>
|
||
and "BeOS(TM)" is selected.
|
||
<a class="link" href="BTextView.html#BTextView_GetSelection" title="GetSelection()"><code class="methodname">GetSelection()</code></a>
|
||
would return 4 and 11 as the offsets that enclose the selection. The
|
||
character 'B' occupies the fourth byte of text and the space following the
|
||
trademark symbol is the eleventh byte of text. The characters in
|
||
"BeOS" are each encoded in one byte, but '(TM) ' takes up three
|
||
bytes in UTF-8. Thus the five-character selection occupies 7 bytes (and
|
||
offsets) of text.
|
||
</p><p>
|
||
Although offsets count bytes, they can also be thought of as designating
|
||
positions between characters. The position at the beginning of the text
|
||
is offset 0, the position between the space and the 'B' in the example
|
||
above is at offset 4, the position between the '(TM) ' and the space is
|
||
at offset 11, and so on. Thus, even if no characters are selected, the
|
||
insertion point (and location of the caret) can still be designated by an
|
||
offset.
|
||
</p><p>
|
||
Most <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
functions expect the offsets they're passed to mark
|
||
positions between characters; the results are not defined if a
|
||
character-internal offset is specified instead.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id559941"></a>Graphics Primitives</h3></div></div></div><p>
|
||
The <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>'s
|
||
mechanism for formatting and drawing text uses the
|
||
graphics primitives it inherits from the
|
||
<a class="link" href="BView.html" title="BView">"<code class="classname">BView</code></a> class. However, it largely
|
||
presents its own API for determining the appearance of the text it draws.
|
||
You should not attempt to affect the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
by calling primitive
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>
|
||
functions like
|
||
<a class="link" href="BView.html#BView_MovePenTo"><code class="methodname">MovePenTo()</code></a>,
|
||
<a class="link" href="BView.html#BView_SetFont" title="SetFont(), GetFont()"><code class="methodname">SetFont()</code></a>, or
|
||
<a class="link" href="BView.html#BView_SetHighColor" title="SetHighColor(), HighColor() , SetLowColor() , LowColor()"><code class="methodname">SetHighColor()</code></a>. Instead, use
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
functions like
|
||
<a class="link" href="BTextView.html#BTextView_SetFontAndColor" title="SetFontAndColor(), GetFontAndColor()"><code class="methodname">SetFontAndColor()</code></a>
|
||
and let the object take care of formatting and drawing the text.
|
||
</p><p>
|
||
The one inherited function that can influence the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a> is
|
||
<a class="link" href="BView.html#BView_SetViewColor" title="SetViewColor(), ViewColor()"><code class="methodname">SetViewColor()</code></a>.
|
||
This function determines the background against which the
|
||
text is drawn and the color that is used in antialiasing calculations.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id560044"></a>Resizing</h3></div></div></div><p>
|
||
A <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
can be made to resize itself to exactly fit the text that the
|
||
user enters. This is sometimes appropriate for small one-line text
|
||
fields. See the
|
||
<a class="link" href="BTextView.html#BTextView_MakeResizable" title="MakeResizable(), IsResizable()"><code class="methodname">MakeResizable()</code></a> function.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id560071"></a>BTextView and BScrollBars</h3></div></div></div><p>
|
||
If you add scrollbars to control the position of the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>'s
|
||
document—this includes using a <a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a> as the target of a
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>BScrollView—the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
will update the scrollbars for you. (Note that it doesn't own the
|
||
scrollbars; you still have to delete them yourself if you created them.)
|
||
When the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
is first displayed and thereafter resized, the scrollbars' ranges, step
|
||
sizes, and scroller positions and proportions are automatically reset to
|
||
reflect the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
object's bounds. Attempts to set these parameters directly (through
|
||
<a class="link" href="BScrollBar.html#BScrollBar_SetRange" title="SetRange(), GetRange()"><code class="methodname">BScrollBar::SetRange()</code></a>
|
||
etc.), are worse than ignored; they're actually applied, and then (at some point) the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
will notice the change in the scrollbars and reset them. Looks like flicker to me.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BTextView_Overview_ShortcutsAndMenuItems"></a>Shortcuts and Menu Items</h3></div></div></div><p>
|
||
When it's the focus view for its window, a
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
automatically responds to a set of keyboard shortcuts:
|
||
</p><ul class="itemizedlist"><li><p>
|
||
<span class="keycap">Command</span>+<span class="keycap">x</span>
|
||
cuts text and copies it to the clipboard
|
||
</p></li><li><p>
|
||
<span class="keycap">Command</span>+<span class="keycap">c</span>
|
||
copies text to the clipboard without cutting it
|
||
</p></li><li><p>
|
||
<span class="keycap">Command</span>+<span class="keycap">v</span>
|
||
pastes text taken from the clipboard
|
||
</p></li><li><p>
|
||
<span class="keycap">Command</span>+<span class="keycap">a</span>
|
||
selects all of the text in the
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>
|
||
</p></li><li><p>
|
||
<span class="keycap">Command</span>+<span class="keycap">z</span>
|
||
undoes the previous action
|
||
</p></li></ul><p>
|
||
If you create menu items for these actions, you have to assign the
|
||
<a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>
|
||
shortcuts and command constants yourself:
|
||
</p><div class="informaltable"><table border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Action</th><th>Constant</th><th>Shortcut</th></tr></thead><tbody><tr><td>Select all</td><td><code class="constant">B_SELECT_ALL</code></td><td><span class="keycap">Command</span>+<span class="keycap">a</span></td></tr><tr><td>Cut</td><td><code class="constant">B_CUT</code></td><td><span class="keycap">Command</span>+<span class="keycap">x</span></td></tr><tr><td>Copy</td><td><code class="constant">B_COPY</code></td><td><span class="keycap">Command</span>+<span class="keycap">c</span></td></tr><tr><td>Paste</td><td><code class="constant">B_PASTE</code></td><td><span class="keycap">Command</span>+<span class="keycap">v</span></td></tr><tr><td>Undo</td><td><code class="constant">B_UNDO</code></td><td><span class="keycap">Command</span>+<span class="keycap">z</span></td></tr></tbody></table></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BTextControl_Overview.html">BTextControl</a> Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a> Next: <a href="BView_Overview.html">BView</a> </div><div id="footerB"><div id="footerBL"><a href="BTextControl_Overview.html" title="BTextControl"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BView_Overview.html" title="BView"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|