to draw outside the normal client area of a window or on an arbitrary place on the screen, even if it is not inside your window.
■ Other kinds of device contexts, such as wx.MemoryDC or wx.BufferedDC, allow you to draw directly to memory for the purpose of buffering draw operations until you are ready to show the completed image on screen. The wx.BufferedDC and wx.BufferedPaintDC classes allow a simple shortcut to managing buffered drawing.
■ Several different methods allow you to draw lines or geometric shapes to a device context. Many of them have secondary forms allowing you to pass wx.Size or wx.Point instances to them directly rather than having to break them out into component pieces. You can draw text to the device context, either straight or rotated an arbitrary number of degrees. Helper methods allow you to manage the font, and determine how much space on the screen your text will cover.
■ In addition to being able to draw a bitmap to the device context, you can perform a Blit() which allows you to rapidly copy part of the content of one device context to another. You can also draw an icon to the device context.
■ You control the color and style of your drawing with a wx.Pen instance, which handles foreground drawing, and a wx.Brush instance, which handles background filling. In both cases, the device context maintains a current value for the object, which you can change at will. You can set the color and style for both objects, and for a pen you can also manage the width and dash pattern. The exact way in which the source pixel from the pen is combined with the color already existing in the device context is computed with the logical function—the default is to just copy the source over the destination, but there are a variety of other flavors to choose from.
■ The device context draws in physical coordinates, meaning pixels, but you can set a parallel logical scale in inches or millimeters, and convert all your coordinates to their physical pixel values when you draw. You can also set the clipping region, which sets a rectangle in your device context as being the only area in which drawing should actually take place. The inverse of the clipping region is the bounding box, which is the rectangle representing the region of your device context in which drawing has already taken place.
Was this article helpful?