wx.ReadOnlyDC¶Base class for device context not providing any drawing functions.
Objects of this class can’t be created directly, please see wx.DC for the description of how to create objects of the derived classes.
Please note that all wxWidgets functions taking parameters of this type added before wxWidgets 3.3.0 used to take wx.DC instead and that they can still be called with wx.DC objects, as wx.DC inherits from wx.ReadOnlyDC.
Added in version 4.3/wxWidgets-3.3.0.
Class Hierarchy¶
Inheritance diagram for class ReadOnlyDC:
Known Subclasses¶wx.DC, InfoDC
Methods Summary¶Does the DC support drawing bitmaps? |
|
Does the DC support calculating the size required to draw text? |
|
Check if the use of transformation matrix is supported by the current system. |
|
Converts device (x, y) coordinates to logical coordinates taking into account all applied transformations like the current mapping mode, scale factors, device origin, axes orientation, affine transformation. |
|
Converts device x, y coordinates to relative logical coordinates taking into account all applied transformations like the current mapping mode, scale factors, affine transformation. |
|
Convert device X coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation. |
|
Convert device X coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation. |
|
Converts device Y coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation. |
|
Convert device Y coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation. |
|
Convert DPI-independent pixel values to the value in pixels appropriate for the DC. |
|
Gets the character height of the currently set font. |
|
Gets the average character width of the currently set font. |
|
Returns the factor used for converting logical pixels to physical ones. |
|
Returns the depth (number of bits/pixel) of this DC. |
|
Returns the current device origin. |
|
Gets the current font. |
|
Returns the various font characteristics. |
|
Gets the current layout direction of the device context. |
|
Return the coordinates of the logical point (0, 0). |
|
Return the scale set by the last call to |
|
Gets the current mapping mode for the device context. |
|
Gets the dimensions of the string as it would be drawn. |
|
Returns the resolution of the device in pixels per inch. |
|
Fills the widths array with the widths from the beginning of text to the corresponding character of text. |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
|
Gets the dimensions of the string as it would be drawn. |
|
Return the transformation matrix used by this device context. |
|
Gets the current user scale factor. |
|
Returns |
|
Converts logical (x, y) coordinates to device coordinates taking into account all applied transformations like the current mapping mode, scale factors, device origin, axes orientation, affine transformation. |
|
Converts logical x, y coordinates to relative device coordinates taking into account all applied transformations like the current mapping mode, scale factors, affine transformation. |
|
Converts logical X coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation. |
|
Converts logical X coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation. |
|
Converts logical Y coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation. |
|
Converts logical Y coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation. |
|
Revert the transformation matrix to identity matrix. |
|
Sets the x and y axis orientation (i.e. the direction from lowest to highest values on the axis). |
|
Sets the device origin (i.e. the origin in pixels after scaling has been applied). |
|
Sets the current font for the DC. |
|
Sets the current layout direction for the device context. |
|
Change the offset used for translating wx.DC coordinates. |
|
Set the scale to use for translating wx.DC coordinates to the physical pixels. |
|
The mapping mode of the device context defines the unit of measurement used to convert logical units to device units. |
|
Set the transformation matrix. |
|
Sets the user scaling factor, useful for applications which require ‘zooming’. |
|
Convert pixel values of the current DC to DPI-independent pixel values. |
Properties Summary¶See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
Class API¶Base class for device context not providing any drawing functions.
Does the DC support drawing bitmaps?
bool
Does the DC support calculating the size required to draw text?
bool
Check if the use of transformation matrix is supported by the current system.
This function returns True for MSW and GTK+ 3 platforms and since 3.1.1 also for wx.GCDC in all ports.
bool
Added in version 2.9.2.
DeviceToLogical (self, x, y)
Converts device (x, y) coordinates to logical coordinates taking into account all applied transformations like the current mapping mode, scale factors, device origin, axes orientation, affine transformation.
x (int)
y (int)
Added in version 4.1/wxWidgets-3.1.5.
DeviceToLogical (self, pt)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Added in version 4.1/wxWidgets-3.1.5.
DeviceToLogicalRel (self, x, y)
Converts device x, y coordinates to relative logical coordinates taking into account all applied transformations like the current mapping mode, scale factors, affine transformation.
Use this for converting distances like e.g. width and height.
x (int)
y (int)
Added in version 4.1/wxWidgets-3.1.5.
DeviceToLogicalRel (self, dim)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Added in version 4.1/wxWidgets-3.1.5.
Convert device X coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
x (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Convert device X coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
Use this for converting a horizontal distance like for example a width.
x (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Converts device Y coordinate to logical coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
y (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Convert device Y coordinate to relative logical coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
Use this for converting a vertical distance like for example a height.
y (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
FromDIP (self, sz)
Convert DPI-independent pixel values to the value in pixels appropriate for the DC.
See Window.FromDIP(const Size& sz) for more info about converting device independent pixel values.
Added in version 4.1/wxWidgets-3.1.7.
FromDIP (self, pt)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
FromDIP (self, d)
Convert DPI-independent value in pixels to the value in pixels appropriate for the DC.
This is the same as FromDIP(const Size& sz) overload, but assumes that the resolution is the same in horizontal and vertical directions.
d (int)
int
Added in version 4.1/wxWidgets-3.1.7.
Gets the character height of the currently set font.
int
Gets the average character width of the currently set font.
int
Returns the factor used for converting logical pixels to physical ones.
Returns the same value as wx.Window.GetDPIScaleFactor for the device contexts associated with a window and the same value as wx.Bitmap.GetScaleFactor for the associated bitmap for wx.MemoryDC.
float
Added in version 2.9.5.
Note
Beware that since wxWidgets 3.1.6, this function does not return the same value as wx.Window.GetContentScaleFactor for the device contexts associated with the window. Unlike wx.Window method, it always returns the effective scale factor instead of always returning 1 on platforms where logical pixels are the same as physical ones, such as MSW.
Returns the depth (number of bits/pixel) of this DC.
int
See also
Returns the current device origin.
See also
Gets the current font.
Notice that even although each device context object has some default font after creation, this method would return a wx.NullFont initially and only after calling SetFont a valid font is returned.
Returns the various font characteristics.
This method allows retrieving some of the font characteristics not returned by GetTextExtent , notably internal leading and average character width.
Currently this method returns correct results only under wxMSW, in the other ports the internal leading will always be 0 and the average character width will be computed as the width of the character ‘x’.
Added in version 2.9.2.
Gets the current layout direction of the device context.
On platforms where RTL layout is supported, the return value will either be Layout_LeftToRight or Layout_RightToLeft . If RTL layout is not supported, the return value will be Layout_Default .
See also
Return the coordinates of the logical point (0, 0).
Tuple[int, int]
See also
Return the scale set by the last call to SetLogicalScale .
Tuple[float, float]
Gets the current mapping mode for the device context.
See also
Gets the dimensions of the string as it would be drawn.
The string parameter is the string to measure. The return value
is a tuple of integer values consisting of widget, height and
heightLine. The heightLine is the the height of a single line.
If the optional parameter font is specified and valid, then it is
used for the text extent calculation. Otherwise the currently selected
font is.
Note
This function works with both single-line and multi-line strings.
string (string)
font (wx.Font)
Tuple[int, int, int]
Fills the widths array with the widths from the beginning of text to the corresponding character of text.
The generic version simply builds a running total of the widths of each character using GetTextExtent , however if the various platforms have a native API function that is faster or more accurate than the generic implementation then it should be used instead.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Gets the dimensions of the string as it would be drawn.
The string parameter is the string to measure. The return value
is a tuple of integer values consisting of widget, height,
decent and externalLeading. The descent is the dimension
from the baseline of the font to the bottom of the descender, and
externalLeading is any extra vertical space added to the font by the
font designer (usually is zero).
If the optional parameter font is specified and valid, then it is
used for the text extent calculation. Otherwise the currently selected
font is.
string (string)
font (wx.Font)
Tuple[int, int, int, int]
Return the transformation matrix used by this device context.
By default the transformation matrix is the identity matrix.
Added in version 2.9.2.
Gets the current user scale factor.
Returns True if the DC is ok to use.
bool
LogicalToDevice (self, x, y)
Converts logical (x, y) coordinates to device coordinates taking into account all applied transformations like the current mapping mode, scale factors, device origin, axes orientation, affine transformation.
x (int)
y (int)
Added in version 4.1/wxWidgets-3.1.5.
LogicalToDevice (self, pt)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Added in version 4.1/wxWidgets-3.1.5.
LogicalToDeviceRel (self, x, y)
Converts logical x, y coordinates to relative device coordinates taking into account all applied transformations like the current mapping mode, scale factors, affine transformation.
Use this for converting distances like e.g. width and height.
x (int)
y (int)
Added in version 4.1/wxWidgets-3.1.5.
LogicalToDeviceRel (self, dim)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Added in version 4.1/wxWidgets-3.1.5.
Converts logical X coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
x (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Converts logical X coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
Use this for converting a horizontal distance like for example a width.
x (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Converts logical Y coordinate to device coordinate, using the current mapping mode, user scale factor, device origin and axis orientation.
y (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Converts logical Y coordinate to relative device coordinate, using the current mapping mode and user scale factor but ignoring the axis orientation.
Use this for converting a vertical distance like for example a height.
y (int)
int
Note
Affine transformation applied to the coordinate system with SetTransformMatrix is not taken into account.
Revert the transformation matrix to identity matrix.
None
Added in version 2.9.2.
Sets the x and y axis orientation (i.e. the direction from lowest to highest values on the axis).
The default orientation is x axis from left to right and y axis from top down.
xLeftRight (bool) – True to set the x axis orientation to the natural left to right orientation, False to invert it.
yBottomUp (bool) – True to set the y axis orientation to the natural bottom up orientation, False to invert it.
None
Sets the device origin (i.e. the origin in pixels after scaling has been applied).
This function may be useful in Windows printing operations for placing a graphic on a page.
x (int)
y (int)
None
Sets the current font for the DC.
The font parameter should be valid, although in wxMSW port (only) the argument wx.NullFont is also accepted and resets the device context font to the default value used by the system (which is not generally useful).
font (wx.Font)
None
See also
Sets the current layout direction for the device context.
dir (LayoutDirection) – May be either Layout_Default , Layout_LeftToRight or Layout_RightToLeft .
None
See also
Change the offset used for translating wx.DC coordinates.
x (int)
y (int)
None
See also
Set the scale to use for translating wx.DC coordinates to the physical pixels.
The effect of calling this function is similar to that of calling SetUserScale .
x (float)
y (float)
None
The mapping mode of the device context defines the unit of measurement used to convert logical units to device units.
Note that in X, text drawing isn’t handled consistently with the mapping mode; a font is always specified in point size. However, setting the user scale (see SetUserScale ) scales the text appropriately. In Windows, scalable TrueType fonts are always used; in X, results depend on availability of fonts, but usually a reasonable match is found.
The coordinate origin is always at the top left of the screen/printer.
Drawing to a Windows printer device context uses the current mapping mode, but mapping mode is currently ignored for PostScript output.
mode (MappingMode)
None
Set the transformation matrix.
If transformation matrix is supported on the current system, the specified matrix will be used to transform between wx.DC and physical coordinates. Otherwise the function returns False and doesn’t change the coordinate mapping.
matrix (wx.AffineMatrix2D)
bool
Added in version 2.9.2.
Sets the user scaling factor, useful for applications which require ‘zooming’.
xScale (float)
yScale (float)
None
ToDIP (self, sz)
Convert pixel values of the current DC to DPI-independent pixel values.
See Window.ToDIP(const Size& sz) for more info about converting device independent pixel values.
Added in version 4.1/wxWidgets-3.1.7.
ToDIP (self, pt)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ToDIP (self, d)
Convert pixel values of the current DC to DPI-independent pixel values.
This is the same as ToDIP(const Size& sz) overload, but assumes that the resolution is the same in horizontal and vertical directions.
d (int)
int
Added in version 4.1/wxWidgets-3.1.7.
See GetCharHeight
See GetCharWidth
See GetDeviceOrigin
See GetFontMetrics
See GetLayoutDirection and SetLayoutDirection
See GetMapMode and SetMapMode
See GetTransformMatrix and SetTransformMatrix