# HG changeset patch # User Frank Benoit # Date 1213966097 -7200 # Node ID 56fea7e5f0f9b2f9d31db17942c6988360436d0a # Parent 028aedd523ad34c5c752efc2228cb0a4a3a5ad11 Fix some runtime errors diff -r 028aedd523ad -r 56fea7e5f0f9 dwtx/ui/forms/widgets/ExpandableComposite.d --- a/dwtx/ui/forms/widgets/ExpandableComposite.d Fri Jun 20 13:00:15 2008 +0200 +++ b/dwtx/ui/forms/widgets/ExpandableComposite.d Fri Jun 20 14:48:17 2008 +0200 @@ -643,39 +643,8 @@ final Label label = new Label(this, DWT.WRAP); if (!isFixedStyle()) { label.setCursor(FormsResources.getHandCursor()); - Listener listener = dgListener( (Event e, Label label) { - switch (e.type) { - case DWT.MouseDown: - if (toggle !is null) - toggle.setFocus(); - break; - case DWT.MouseUp: - label.setCursor(FormsResources.getBusyCursor()); - programmaticToggleState(); - label.setCursor(FormsResources.getHandCursor()); - break; - case DWT.MouseEnter: - if (toggle !is null) { - label.setForeground(toggle - .getHoverDecorationColor()); - toggle.hover_package = true; - toggle.redraw(); - } - break; - case DWT.MouseExit: - if (toggle !is null) { - label.setForeground(getTitleBarForeground()); - toggle.hover_package = false; - toggle.redraw(); - } - break; - case DWT.Paint: - if (toggle !is null) { - paintTitleFocus(e.gc); - } - break; - } - }, label ); + // DWT FIXME: workaround for DMD anonymous class, nested function problem + Listener listener = dgListener( &tst, label ); label.addListener(DWT.MouseDown, listener); label.addListener(DWT.MouseUp, listener); label.addListener(DWT.MouseEnter, listener); @@ -705,6 +674,40 @@ } } + // DWT FIXME: workaround for DMD anonymous class, nested function problem + void tst(Event e, Label label_) { + switch (e.type) { + case DWT.MouseDown: + if (toggle !is null) + toggle.setFocus(); + break; + case DWT.MouseUp: + label_.setCursor(FormsResources.getBusyCursor()); + programmaticToggleState(); + label_.setCursor(FormsResources.getHandCursor()); + break; + case DWT.MouseEnter: + if (toggle !is null) { + label_.setForeground(toggle + .getHoverDecorationColor()); + toggle.hover_package = true; + toggle.redraw(); + } + break; + case DWT.MouseExit: + if (toggle !is null) { + label_.setForeground(getTitleBarForeground()); + toggle.hover_package = false; + toggle.redraw(); + } + break; + case DWT.Paint: + if (toggle !is null) { + paintTitleFocus(e.gc); + } + break; + } + } /* (non-Javadoc) * @see dwt.widgets.Control#forceFocus() */ diff -r 028aedd523ad -r 56fea7e5f0f9 dwtx/ui/forms/widgets/FormText.d --- a/dwtx/ui/forms/widgets/FormText.d Fri Jun 20 13:00:15 2008 +0200 +++ b/dwtx/ui/forms/widgets/FormText.d Fri Jun 20 14:48:17 2008 +0200 @@ -1552,7 +1552,7 @@ } private void ensureBoldFontPresent(Font regularFont) { - Font boldFont = cast(Font) resourceTable.get(FormTextModel.BOLD_FONT_ID); + Font boldFont = resourceTable.containsKey(FormTextModel.BOLD_FONT_ID) ? cast(Font) resourceTable.get(FormTextModel.BOLD_FONT_ID) : null; if (boldFont !is null) return; boldFont = FormFonts.getInstance().getBoldFont(getDisplay(), regularFont); diff -r 028aedd523ad -r 56fea7e5f0f9 dwtx/ui/forms/widgets/FormToolkit.d --- a/dwtx/ui/forms/widgets/FormToolkit.d Fri Jun 20 13:00:15 2008 +0200 +++ b/dwtx/ui/forms/widgets/FormToolkit.d Fri Jun 20 14:48:17 2008 +0200 @@ -305,7 +305,14 @@ */ public Composite createCompositeSeparator(Composite parent) { final Composite composite = new Composite(parent, orientation); - composite.addListener(DWT.Paint, dgListener( (Event e, Composite composite) { + // DWT FIXME: problem with DMD and anonclass/nested func + composite.addListener(DWT.Paint, dgListener( &dwtWorkaround, composite)); + if (null !is cast(Section)parent ) + (cast(Section) parent).setSeparatorControl(composite); + return composite; + } + // DWT FIXME: problem with DMD and anonclass/nested func + private void dwtWorkaround (Event e, Composite composite) { if (composite.isDisposed()) return; Rectangle bounds = composite.getBounds(); @@ -315,12 +322,7 @@ gc.setBackground(colors.getBackground()); gc.fillGradientRectangle(0, 0, bounds.width, bounds.height, false); - }, composite)); - if (null !is cast(Section)parent ) - (cast(Section) parent).setSeparatorControl(composite); - return composite; - } - + } /** * Creates a label as a part of the form. * diff -r 028aedd523ad -r 56fea7e5f0f9 dwtx/ui/forms/widgets/TableWrapLayout.d --- a/dwtx/ui/forms/widgets/TableWrapLayout.d Fri Jun 20 13:00:15 2008 +0200 +++ b/dwtx/ui/forms/widgets/TableWrapLayout.d Fri Jun 20 14:48:17 2008 +0200 @@ -339,7 +339,7 @@ size = new Point(size.x, td.heightHint); } td.compSize = size; - RowSpan rowspan = cast(RowSpan) rowspans.get(child); + RowSpan rowspan = rowspans.containsKey(child) ? cast(RowSpan) rowspans.get(child) : null; if (rowspan is null) { rowHeights[i] = Math.max(rowHeights[i], size.y); } else @@ -431,7 +431,7 @@ int width = td.compSize.x-td.indent; width = Math.min(width, colWidth); int slotHeight = rowHeights[row]; - RowSpan rowspan = cast(RowSpan) rowspans.get(control); + RowSpan rowspan = rowspans.containsKey(control) ? cast(RowSpan) rowspans.get(control) : null; if (rowspan !is null) { slotHeight = 0; for (int i = row; i < row + td.rowspan; i++) { @@ -687,7 +687,7 @@ Point size = computeSize(td.childIndex, cwidth, td.indent, td.maxWidth, td.maxHeight); cy = size.y; } - RowSpan rowspan = cast(RowSpan) rowspans.get(child); + RowSpan rowspan = rowspans.containsKey(child) ? cast(RowSpan) rowspans.get(child) : null; if (rowspan !is null) { // don't take the height of this child into acount // because it spans multiple rows diff -r 028aedd523ad -r 56fea7e5f0f9 dwtx/ui/internal/forms/widgets/FormFonts.d --- a/dwtx/ui/internal/forms/widgets/FormFonts.d Fri Jun 20 13:00:15 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormFonts.d Fri Jun 20 14:48:17 2008 +0200 @@ -85,7 +85,7 @@ public Font getBoldFont(Display display, Font font) { checkHashMaps(); FontIdentifier fid = new FontIdentifier(display, font); - FontReference result = cast(FontReference) fonts.get(fid); + FontReference result = fonts.containsKey(fid) ? cast(FontReference) fonts.get(fid) : null; if (result !is null && !result.getFont().isDisposed()) { result.incCount(); return result.getFont();