Class Device
- All Implemented Interfaces:
- Drawable
- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionDevice()Constructs a new instance of this class.Device(DeviceData data) Constructs a new instance of this class.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidThrows anSWTExceptionif the receiver can not be accessed by the caller.protected voidcreate(DeviceData data) Creates the device in the operating system.protected voiddestroy()Destroys the device in the operating system and releases the device's handle.voiddispose()Disposes of the operating system resources associated with the receiver.Returns a rectangle describing the receiver's size and location.Returns a rectangle which describes the area of the receiver which is capable of displaying data.intgetDepth()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.Returns aDeviceDatabased on the receiver.protected intGets the scaling factor from the device and calculates the zoom level.getDPI()Returns a point whose x coordinate is the logical horizontal dots per inch of the display, and whose y coordinate is the logical vertical dots per inch of the display.FontData[]getFontList(String faceName, boolean scalable) ReturnsFontDataobjects which describe the fonts that match the given arguments.getSystemColor(int id) Returns the matching standard color for the given constant, which should be one of the color constants specified in classSWT.Returns a reasonable font for applications to use.booleanReturnstrueif the underlying window system prints out warning messages on the console, andsetWarningshad previously been called withtrue.protected voidinit()Initializes any internal resources needed by the device.abstract voidinternal_dispose_GC(long hDC, GCData data) Invokes platform specific functionality to dispose a GC handle.abstract longinternal_new_GC(GCData data) Invokes platform specific functionality to allocate a new GC handle.booleanReturnstrueif the device has been disposed, andfalseotherwise.booleanbooleanLoads the font specified by a file.protected voidrelease()Releases any internal resources back to the operating system and clears all fields except the device handle.voidsetTracking(boolean tracking) voidsetWarnings(boolean warnings) If the underlying window system supports printing warning messages to the console, setting warnings tofalseprevents these messages from being printed.static voidwin32_destroyUnusedHandles(Display display) Destroys the handles of all the resources in the resource tracker by identifying the zoom levels which is not valid for any monitorMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.swt.graphics.DrawableisAutoScalable
- 
Field Details- 
DEBUGpublic static boolean DEBUG
- 
CurrentDevice
- 
DeviceFinder
 
- 
- 
Constructor Details- 
Devicepublic Device()Constructs a new instance of this class.You must dispose the device when it is no longer required. - Since:
- 3.1
- See Also:
 
- 
DeviceConstructs a new instance of this class.You must dispose the device when it is no longer required. - Parameters:
- data- the DeviceData which describes the receiver
- See Also:
 
 
- 
- 
Method Details- 
isTrackingpublic boolean isTracking()- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
- Since:
- 3.115
 
- 
setTrackingpublic void setTracking(boolean tracking) - Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
- Since:
- 3.115
 
- 
checkDeviceprotected void checkDevice()Throws anSWTExceptionif 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()anddispose()) on a device that has had itsdispose()method called.In future releases of SWT, there may be more or fewer error checks and exceptions may be thrown for different reasons. - Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
 
 
- 
createCreates the device in the operating system. If the device does not have a handle, this method may do nothing depending on the device.This method is called before init.Subclasses are supposed to reimplement this method and not call the superimplementation.- Parameters:
- data- the DeviceData which describes the receiver
- See Also:
 
- 
destroyprotected void destroy()Destroys the device in the operating system and releases the device's handle. If the device does not have a handle, this method may do nothing depending on the device.This method is called after release.Subclasses are supposed to reimplement this method and not call the superimplementation.- See Also:
 
- 
disposepublic void dispose()Disposes of the operating system resources associated with the receiver. After this method has been invoked, the receiver will answertruewhen sent the messageisDisposed().- See Also:
 
- 
getBoundsReturns a rectangle describing the receiver's size and location.- Returns:
- the bounding rectangle
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
getDeviceDataReturns aDeviceDatabased on the receiver. Modifications made to thisDeviceDatawill not affect the receiver.- Returns:
- a DeviceDatacontaining the device's data and attributes
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
- See Also:
 
- 
getClientAreaReturns a rectangle which describes the area of the receiver which is capable of displaying data.- Returns:
- the client area
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
- See Also:
 
- 
getDepthpublic 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. This number will typically be one of 1, 8, 15, 16, 24 or 32.- Returns:
- the depth of the screen
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
getDPIReturns a point whose x coordinate is the logical horizontal dots per inch of the display, and whose y coordinate is the logical vertical dots per inch of the display.- Returns:
- the horizontal and vertical DPI
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
getFontListReturnsFontDataobjects which describe the fonts that match the given arguments. If thefaceNameis null, all fonts will be returned.- Parameters:
- faceName- the name of the font to look for, or null
- scalable- if true only scalable fonts are returned, otherwise only non-scalable fonts are returned.
- Returns:
- the matching font data
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
getSystemColorReturns the matching standard color for the given constant, which should be one of the color constants specified in classSWT. 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.- Parameters:
- id- the color constant
- Returns:
- the matching color
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
- See Also:
 
- 
getSystemFontReturns a reasonable font for applications to use. On some platforms, this will match the "default font" or "system font" if such can be found. This font should not be freed because it was allocated by the system, not the application.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. - Returns:
- a font
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
getWarningspublic boolean getWarnings()Returnstrueif the underlying window system prints out warning messages on the console, andsetWarningshad previously been called withtrue.- Returns:
- trueif warnings are being handled, and- falseotherwise
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
initprotected void init()Initializes any internal resources needed by the device.This method is called after create.If subclasses reimplement this method, they must call the superimplementation.- See Also:
 
- 
internal_new_GCInvokes platform specific functionality to allocate a new GC handle.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.- Specified by:
- internal_new_GCin interface- Drawable
- Parameters:
- data- the platform specific GC data
- Returns:
- the platform specific GC handle
- Restriction:
- This method is not intended to be referenced by clients.
 
- 
internal_dispose_GCInvokes platform specific functionality to dispose a GC handle.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.- Specified by:
- internal_dispose_GCin interface- Drawable
- Parameters:
- hDC- the platform specific GC handle
- data- the platform specific GC data
- Restriction:
- This method is not intended to be referenced by clients.
 
- 
isDisposedpublic boolean isDisposed()Returnstrueif the device has been disposed, andfalseotherwise.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. - Returns:
- truewhen the device is disposed and- falseotherwise
 
- 
loadFontLoads the font specified by a file. The font will be present in the list of fonts available to the application.- Parameters:
- path- the font file path
- Returns:
- whether the font was successfully loaded
- Throws:
- SWTException-- ERROR_NULL_ARGUMENT - if path is null
- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
- Since:
- 3.3
- See Also:
 
- 
releaseprotected void release()Releases any internal resources back to the operating system and clears all fields except the device handle.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 This method is called beforerelease. 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 bydestroy.destroy.If subclasses reimplement this method, they must call the superimplementation.- See Also:
 
- 
setWarningspublic void setWarnings(boolean warnings) If the underlying window system supports printing warning messages to the console, setting warnings tofalseprevents these messages from being printed. If the argument istruethen message printing is not blocked.- Parameters:
- warnings-- trueif warnings should be printed, and- falseotherwise
- Throws:
- SWTException-- ERROR_DEVICE_DISPOSED - if the receiver has been disposed
 
 
- 
getDeviceZoomprotected int getDeviceZoom()Gets the scaling factor from the device and calculates the zoom level.- Returns:
- zoom in percentage
- Since:
- 3.105
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
 
- 
win32_destroyUnusedHandlesDestroys the handles of all the resources in the resource tracker by identifying the zoom levels which is not valid for any monitor- Restriction:
- This method is not intended to be referenced by clients.
 
 
-