blob: e9dcba801ff650918b40e286a611d3006b9e3f70 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE>
Color and font management
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>
Color and font management</H1>
<p align="left">When using forms in a non-trivial way, it is important to share
as much as possible to conserve resources. For this reason, color management
should be separated from the toolkit when there are more than one form to
handle.</p>
<p align="left">Of course, it is possible to create one toolkit per form, but
that is too wasteful if there are many forms. Instead:</p>
<ul>
<li>
<p align="left">Create one toolkit for all the forms that have the same life
cycle. For example, if creating a multi-page editor, create one toolkit per
editor and dispose it when editor is disposed. All the pages in the editor
should share this toolkit.</p></li>
<li>
<p align="left">Create one color manager (<code>FormColors</code>) per
plug-in. When creating the toolkit, pass the color manager to the toolkit.
The toolkit will know that the colors are shared and will not dispose them.</p>
</li>
<li>
<p align="left">Use platform support for fonts and if possible, use <code>
JFaceResources</code> predefined fonts. Between default, 'banner' and
'header' fonts, you can accomplish a lot. Using many fonts is very confusing
for the user, and if you do manage your own, you must ensure alternatives
across platforms. The JFace fonts are guaranteed to work on all the
platforms Eclipse ships on.</p></li>
<li>
<p align="left">Dispose the color manager on plug-in shutdown (don't assume
that plug-in shutdown also means platform shutdown - Eclipse runtime can
uninstall your plug-in dynamically while the platform is still running).</p></li>
<li>
<p align="left">Use form color manager to allocate all the colors needed by
the forms.</p></li>
</ul>
</BODY>
</HTML>