Mercurial > projects > dwt-addons
comparison dwtx/jface/resource/FontRegistry.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | d0467f3a67b3 |
children | 04b47443bb01 |
comparison
equal
deleted
inserted
replaced
89:040da1cb0d76 | 90:7ffeace6c47f |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
68 * <p> | 68 * <p> |
69 * Clients may instantiate this class (it was not designed to be subclassed). | 69 * Clients may instantiate this class (it was not designed to be subclassed). |
70 * </p> | 70 * </p> |
71 * | 71 * |
72 * Since 3.0 this class extends ResourceRegistry. | 72 * Since 3.0 this class extends ResourceRegistry. |
73 * @noextend This class is not intended to be subclassed by clients. | |
73 */ | 74 */ |
74 public class FontRegistry : ResourceRegistry { | 75 public class FontRegistry : ResourceRegistry { |
75 | 76 |
76 /** | 77 /** |
77 * FontRecord is a private helper class that holds onto a font | 78 * FontRecord is a private helper class that holds onto a font |
214 | 215 |
215 /** | 216 /** |
216 * Runnable that cleans up the manager on disposal of the display. | 217 * Runnable that cleans up the manager on disposal of the display. |
217 */ | 218 */ |
218 protected Runnable displayRunnable; | 219 protected Runnable displayRunnable; |
220 | |
221 private bool displayDisposeHooked; | |
222 | |
223 private final bool cleanOnDisplayDisposal; | |
219 | 224 |
220 /** | 225 /** |
221 * Creates an empty font registry. | 226 * Creates an empty font registry. |
222 * <p> | 227 * <p> |
223 * There must be an DWT Display created in the current | 228 * There must be an DWT Display created in the current |
290 Assert.isNotNull(display); | 295 Assert.isNotNull(display); |
291 // FIXE: need to respect loader | 296 // FIXE: need to respect loader |
292 //readResourceBundle(location, loader); | 297 //readResourceBundle(location, loader); |
293 readResourceBundle(location); | 298 readResourceBundle(location); |
294 | 299 |
300 cleanOnDisplayDisposal = true; | |
295 hookDisplayDispose(display); | 301 hookDisplayDispose(display); |
296 } | 302 } |
297 | 303 |
298 private void initInstance(){ | 304 private void initInstance(){ |
299 displayRunnable = new class Runnable { | 305 displayRunnable = new class Runnable { |
408 * @since 3.1 | 414 * @since 3.1 |
409 */ | 415 */ |
410 public this(Display display, bool cleanOnDisplayDisposal) { | 416 public this(Display display, bool cleanOnDisplayDisposal) { |
411 initInstance(); | 417 initInstance(); |
412 Assert.isNotNull(display); | 418 Assert.isNotNull(display); |
419 this.cleanOnDisplayDisposal = cleanOnDisplayDisposal; | |
413 if (cleanOnDisplayDisposal) { | 420 if (cleanOnDisplayDisposal) { |
414 hookDisplayDispose(display); | 421 hookDisplayDispose(display); |
415 } | 422 } |
416 } | 423 } |
417 | 424 |
531 */ | 538 */ |
532 private FontRecord createFont(String symbolicName, FontData[] fonts) { | 539 private FontRecord createFont(String symbolicName, FontData[] fonts) { |
533 Display display = Display.getCurrent(); | 540 Display display = Display.getCurrent(); |
534 if (display is null) { | 541 if (display is null) { |
535 return null; | 542 return null; |
543 } | |
544 if (cleanOnDisplayDisposal && !displayDisposeHooked) { | |
545 hookDisplayDispose(display); | |
536 } | 546 } |
537 | 547 |
538 FontData[] validData = filterData(fonts, display); | 548 FontData[] validData = filterData(fonts, display); |
539 if (validData.length is 0) { | 549 if (validData.length is 0) { |
540 //Nothing specified | 550 //Nothing specified |
730 fnt.dispose(); | 740 fnt.dispose(); |
731 } | 741 } |
732 | 742 |
733 stringToFontRecord.clear(); | 743 stringToFontRecord.clear(); |
734 staleFonts.clear(); | 744 staleFonts.clear(); |
745 | |
746 displayDisposeHooked = false; | |
735 } | 747 } |
736 | 748 |
737 /** | 749 /** |
738 * Hook a dispose listener on the DWT display. | 750 * Hook a dispose listener on the DWT display. |
739 */ | 751 */ |
740 private void hookDisplayDispose(Display display) { | 752 private void hookDisplayDispose(Display display) { |
753 displayDisposeHooked = true; | |
741 display.disposeExec(displayRunnable); | 754 display.disposeExec(displayRunnable); |
742 } | 755 } |
743 | 756 |
744 /** | 757 /** |
745 * Checks whether the given font is in the list of fixed fonts. | 758 * Checks whether the given font is in the list of fixed fonts. |