public abstract class Device extends java.lang.Object implements Drawable
Modifier and Type | Field and Description |
---|---|
(package private) int[] |
colorRefCount |
protected static Device |
CurrentDevice |
(package private) boolean |
debug |
static boolean |
DEBUG |
protected static java.lang.Runnable |
DeviceFinder |
(package private) boolean |
disposed |
(package private) java.lang.Error[] |
errors |
(package private) int |
fontCollection |
(package private) int[] |
gdipToken |
int |
hPalette
Palette
(Warning: This field is platform dependent)
IMPORTANT: This field is not part of the SWT
public API.
|
(package private) java.lang.String[] |
loadedFonts |
(package private) LOGFONT[] |
logFonts |
(package private) TEXTMETRIC |
metrics |
(package private) int |
nFonts |
(package private) java.lang.Object[] |
objects |
(package private) int[] |
pixels |
(package private) int[] |
scripts |
(package private) Font |
systemFont |
(package private) boolean |
tracking |
(package private) java.lang.Object |
trackingLock |
Constructor and Description |
---|
Device()
Constructs a new instance of this class.
|
Device(DeviceData data)
Constructs a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addFont(java.lang.String font) |
protected void |
checkDevice()
Throws an
SWTException if the receiver can not
be accessed by the caller. |
(package private) void |
checkGDIP() |
(package private) int |
computePixels(float height) |
(package private) float |
computePoints(LOGFONT logFont,
int hFont) |
protected void |
create(DeviceData data)
Creates the device in the operating system.
|
protected void |
destroy()
Destroys the device in the operating system and releases
the device's handle.
|
(package private) void |
dispose_Object(java.lang.Object object) |
void |
dispose()
Disposes of the operating system resources associated with
the receiver.
|
(package private) int |
EnumFontFamProc(int lpelfe,
int lpntme,
int FontType,
int lParam) |
Rectangle |
getBounds()
Returns a rectangle describing the receiver's size and location.
|
Rectangle |
getClientArea()
Returns a rectangle which describes the area of the
receiver which is capable of displaying data.
|
int |
getDepth()
Returns the bit depth of the screen, which is the number of
bits it takes to represent the number of unique colors that
the screen is currently capable of displaying.
|
(package private) static Device |
getDevice() |
DeviceData |
getDeviceData()
Returns a
DeviceData based on the receiver. |
Point |
getDPI()
Returns a point whose x coordinate is the horizontal
dots per inch of the display, and whose y coordinate
is the vertical dots per inch of the display.
|
FontData[] |
getFontList(java.lang.String faceName,
boolean scalable)
Returns
FontData objects which describe
the fonts that match the given arguments. |
(package private) java.lang.String |
getLastError() |
(package private) java.lang.String |
getLastErrorText() |
Color |
getSystemColor(int id)
Returns the matching standard color for the given
constant, which should be one of the color constants
specified in class
SWT . |
Font |
getSystemFont()
Returns a reasonable font for applications to use.
|
boolean |
getWarnings()
Returns
true if the underlying window system prints out
warning messages on the console, and setWarnings
had previously been called with true . |
protected void |
init()
Initializes any internal resources needed by the
device.
|
abstract void |
internal_dispose_GC(int hDC,
GCData data)
Invokes platform specific functionality to dispose a GC handle.
|
abstract int |
internal_new_GC(GCData data)
Invokes platform specific functionality to allocate a new GC handle.
|
boolean |
isDisposed()
Returns
true if the device has been disposed,
and false otherwise. |
boolean |
loadFont(java.lang.String path)
Loads the font specified by a file.
|
(package private) void |
new_Object(java.lang.Object object) |
(package private) void |
printErrors() |
protected void |
release()
Releases any internal resources back to the operating
system and clears all fields except the device handle.
|
void |
setWarnings(boolean warnings)
If the underlying window system supports printing warning messages
to the console, setting warnings to
false prevents these
messages from being printed. |
public static boolean DEBUG
boolean debug
boolean tracking
java.lang.Error[] errors
java.lang.Object[] objects
java.lang.Object trackingLock
public int hPalette
IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.
int[] colorRefCount
Font systemFont
int nFonts
LOGFONT[] logFonts
TEXTMETRIC metrics
int[] pixels
int[] scripts
int[] gdipToken
int fontCollection
java.lang.String[] loadedFonts
boolean disposed
protected static Device CurrentDevice
protected static java.lang.Runnable DeviceFinder
public Device()
You must dispose the device when it is no longer required.
create(org.eclipse.swt.graphics.DeviceData)
,
init()
public Device(DeviceData data)
You must dispose the device when it is no longer required.
data
- the DeviceData which describes the receivercreate(org.eclipse.swt.graphics.DeviceData)
,
init()
,
DeviceData
static Device getDevice()
void addFont(java.lang.String font)
protected void checkDevice()
SWTException
if the receiver can not
be accessed by the caller. This may include both checks on
the state of the receiver and more generally on the entire
execution context. This method should be called by
device implementors to enforce the standard SWT invariants.
Currently, it is an error to invoke any method (other than
isDisposed()
and dispose()
) on a
device that has had its dispose()
method called.
In future releases of SWT, there may be more or fewer error checks and exceptions may be thrown for different reasons.
SWTException
- void checkGDIP()
protected void create(DeviceData data)
This method is called before init
.
Subclasses are supposed to reimplement this method and not
call the super
implementation.
data
- the DeviceData which describes the receiverinit()
int computePixels(float height)
float computePoints(LOGFONT logFont, int hFont)
protected void destroy()
This method is called after release
.
Subclasses are supposed to reimplement this method and not
call the super
implementation.
public void dispose()
true
when sent the message
isDisposed()
.release()
,
destroy()
,
checkDevice()
void dispose_Object(java.lang.Object object)
int EnumFontFamProc(int lpelfe, int lpntme, int FontType, int lParam)
public Rectangle getBounds()
SWTException
- public DeviceData getDeviceData()
DeviceData
based on the receiver.
Modifications made to this DeviceData
will not
affect the receiver.DeviceData
containing the device's data and attributesSWTException
- DeviceData
public Rectangle getClientArea()
SWTException
- getBounds()
public int getDepth()
SWTException
- public Point getDPI()
SWTException
- public FontData[] getFontList(java.lang.String faceName, boolean scalable)
FontData
objects which describe
the fonts that match the given arguments. If the
faceName
is null, all fonts will be returned.faceName
- the name of the font to look for, or nullscalable
- if true only scalable fonts are returned, otherwise only non-scalable fonts are returned.SWTException
- java.lang.String getLastError()
java.lang.String getLastErrorText()
public Color getSystemColor(int id)
SWT
. Any value other
than one of the SWT color constants which is passed
in will result in the color black. This color should
not be freed because it was allocated by the system,
not the application.id
- the color constantSWTException
- SWT
public Font getSystemFont()
Typically, applications which want the default look should simply not set the font on the widgets they create. Widgets are always created with the correct default font for the class of user-interface component they represent.
SWTException
- public boolean getWarnings()
true
if the underlying window system prints out
warning messages on the console, and setWarnings
had previously been called with true
.true
if warnings are being handled, and false
otherwiseSWTException
- protected void init()
This method is called after create
.
If subclasses reimplement this method, they must
call the super
implementation.
public abstract int internal_new_GC(GCData data)
IMPORTANT: This method is not part of the public
API for Device
. It is marked public only so that it
can be shared within the packages provided by SWT. It is not
available on all platforms, and should never be called from
application code.
internal_new_GC
in interface Drawable
data
- the platform specific GC datapublic abstract void internal_dispose_GC(int hDC, GCData data)
IMPORTANT: This method is not part of the public
API for Device
. It is marked public only so that it
can be shared within the packages provided by SWT. It is not
available on all platforms, and should never be called from
application code.
internal_dispose_GC
in interface Drawable
hDC
- the platform specific GC handledata
- the platform specific GC datapublic boolean isDisposed()
true
if the device has been disposed,
and false
otherwise.
This method gets the dispose state for the device. When a device has been disposed, it is an error to invoke any other method using the device.
true
when the device is disposed and false
otherwisepublic boolean loadFont(java.lang.String path)
path
- the font file pathSWTException
- Font
void new_Object(java.lang.Object object)
void printErrors()
protected void release()
When a device is destroyed, resources that were acquired
on behalf of the programmer need to be returned to the
operating system. For example, if the device allocated a
font to be used as the system font, this font would be
freed in release
. Also,to assist the garbage
collector and minimize the amount of memory that is not
reclaimed when the programmer keeps a reference to a
disposed device, all fields except the handle are zero'd.
The handle is needed by destroy
.
destroy
.
If subclasses reimplement this method, they must
call the super
implementation.
public void setWarnings(boolean warnings)
false
prevents these
messages from being printed. If the argument is true
then
message printing is not blocked.warnings
- true
if warnings should be printed, and false
otherwiseSWTException
-