cookxml.cookswt.util
Class SwtUtils

java.lang.Object
  extended bycookxml.cookswt.util.SwtUtils

public class SwtUtils
extends Object

SWT useful utilities.

Since:
CookSwt 1.0

Field Summary
static boolean autoDisposeColor
          automatically dispose Color resource
static boolean autoDisposeCursor
          automatically dispose Image resource
static boolean autoDisposeFont
          automatically dispose Font resource
static boolean autoDisposeImage
          automatically dispose Image resource
 
Constructor Summary
SwtUtils()
           
 
Method Summary
static void attachColorDisposeListener(Widget widget, Color color)
          Attach a DisposeListener that dispose the resource when the widget object is disposed.
static void attachCursorDisposeListener(Widget widget, Cursor cursor)
          Attach a DisposeListener that dispose the resource when the widget object is disposed.
static void attachFontDisposeListener(Widget widget, Font font)
          Attach a DisposeListener that dispose the resource when the widget object is disposed.
static void attachImageDisposeListener(Widget widget, Image image)
          Attach a DisposeListener that dispose the resource when the widget object is disposed.
static void attachToolItemDropDownMenu(ToolItem item, Menu menu)
          Attach a dropdown menu to a drop down ToolItem.
static void disposeColor(Color color, Device device)
          Dispose a color if it is not a system color.
static boolean disposeDebug(String msg)
          This function is supposed to work in conjunction with assert to generate a debug message but does not really throw an Exception
static void disposeImage(Image image, Display device)
          Dispose a color if it is not a system color.
static boolean isSystemColor(Color color, Device device)
          Check if a color is a system color.
static boolean isSystemCursor(Cursor cursor, Display display)
          Check if a color is a system color.
static boolean isSystemFont(Font font, Device device)
          Check if a color is a system color.
static boolean isSystemImage(Image image, Display display)
          Check if a color is a system color.
static void showDisplay(Display display)
          Open all the shells inside the Display object and dispose the Display after all shells are disposed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

autoDisposeColor

public static boolean autoDisposeColor
automatically dispose Color resource


autoDisposeFont

public static boolean autoDisposeFont
automatically dispose Font resource


autoDisposeImage

public static boolean autoDisposeImage
automatically dispose Image resource


autoDisposeCursor

public static boolean autoDisposeCursor
automatically dispose Image resource

Constructor Detail

SwtUtils

public SwtUtils()
Method Detail

isSystemColor

public static boolean isSystemColor(Color color,
                                    Device device)
Check if a color is a system color. A system color cannot be disposed.

Parameters:
color - The color to be disposed.
device - The device that contains the color.

isSystemCursor

public static boolean isSystemCursor(Cursor cursor,
                                     Display display)
Check if a color is a system color. A system color cannot be disposed.

Parameters:
cursor - The cursor to be disposed.
display - The display device.

isSystemImage

public static boolean isSystemImage(Image image,
                                    Display display)
Check if a color is a system color. A system color cannot be disposed.

Parameters:
image - The image to be disposed.
display - The display device.

isSystemFont

public static boolean isSystemFont(Font font,
                                   Device device)
Check if a color is a system color. A system color cannot be disposed.

Parameters:
font - The font to be disposed.
device - The display device.

disposeColor

public static void disposeColor(Color color,
                                Device device)
Dispose a color if it is not a system color.

Parameters:
color - The color to be disposed.
device - The device that contains the color.

disposeImage

public static void disposeImage(Image image,
                                Display device)
Dispose a color if it is not a system color.

Parameters:
image - The image to be disposed.
device - The device that contains the color.

attachColorDisposeListener

public static void attachColorDisposeListener(Widget widget,
                                              Color color)
Attach a DisposeListener that dispose the resource when the widget object is disposed.

Parameters:
widget - the widget to listen to.
color - the resource to be disposed.

attachCursorDisposeListener

public static void attachCursorDisposeListener(Widget widget,
                                               Cursor cursor)
Attach a DisposeListener that dispose the resource when the widget object is disposed.

Parameters:
widget - the widget to listen to.
cursor - the resource to be disposed.

attachFontDisposeListener

public static void attachFontDisposeListener(Widget widget,
                                             Font font)
Attach a DisposeListener that dispose the resource when the widget object is disposed.

Parameters:
widget - the widget to listen to.
font - the resource to be disposed.

attachImageDisposeListener

public static void attachImageDisposeListener(Widget widget,
                                              Image image)
Attach a DisposeListener that dispose the resource when the widget object is disposed.

Parameters:
widget - the widget to listen to.
image - the resource to be disposed.

attachToolItemDropDownMenu

public static void attachToolItemDropDownMenu(ToolItem item,
                                              Menu menu)
Attach a dropdown menu to a drop down ToolItem. The drop down menu will be automatically positioned and displayed at under the ToolItem.

Parameters:
item - the drop down tool item
menu - the drop down menu

showDisplay

public static void showDisplay(Display display)
Open all the shells inside the Display object and dispose the Display after all shells are disposed.

Parameters:
display - the Display object.

disposeDebug

public static boolean disposeDebug(String msg)
This function is supposed to work in conjunction with assert to generate a debug message but does not really throw an Exception

Parameters:
msg - the message to be printed.
Returns:
true