Mercurial > projects > dwt-mac
view dwt/internal/theme/Theme.d @ 5:1a8b3cb347e0
Fix Ctors to 'this'
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:02:31 +0200 |
parents | 380af2bdd8e5 |
children | 540fa4e9974a |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ module dwt.internal.theme; import dwt.*; import dwt.graphics.*; public class Theme { Device device; public this(Device device) { this.device = device; } void checkTheme() { if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); } public Rectangle computeTrim(GC gc, DrawData data) { if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); return data.computeTrim(this, gc); } public void dispose () { device = null; } public void drawBackground(GC gc, Rectangle bounds, DrawData data) { checkTheme(); if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); data.draw(this, gc, bounds); } public void drawFocus(GC gc, Rectangle bounds, DrawData data) { checkTheme(); if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height); } public void drawImage(GC gc, Rectangle bounds, DrawData data, Image image, int flags) { checkTheme(); if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); data.drawImage(this, image, gc, bounds); } public void drawText(GC gc, Rectangle bounds, DrawData data, String text, int flags) { checkTheme(); if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); data.drawText(this, text, flags, gc, bounds); } public Rectangle getBounds(int part, Rectangle bounds, DrawData data) { checkTheme(); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); return data.getBounds(part, bounds); } public int getSelection(Point offset, Rectangle bounds, RangeDrawData data) { checkTheme(); if (offset is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); return data.getSelection(offset, bounds); } public int hitBackground(Point position, Rectangle bounds, DrawData data) { checkTheme(); if (position is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); return data.hit(this, position, bounds); } public bool isDisposed() { return device is null; } public Rectangle measureText(GC gc, Rectangle bounds, DrawData data, String text, int flags) { checkTheme(); if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); return data.measureText(this, text, flags, gc, bounds); } }