Device context overview- wxWidgets wxPython

Device context overview

Classes: wxBufferedDC, wxBufferedPaintDC, wxDC, wxPostScriptDC, wxMetafileDC, wxMemoryDC, wxPrinterDC, wxScreenDC, wxClientDC, wxPaintDC, wxWindowDC.

A wxDC is a device context onto which graphics and text can be drawn.The device context is intended to represent a number of output devices in a generic way,with the same API being used throughout.

Some device contexts are created temporarily in order to draw on a window.This is true of wxScreenDC, wxClientDC, wxPaintDC,and wxWindowDC. The following describes the differences betweenthese device contexts and when you should use them.

  • wxScreenDC. Use this to paint on the screen, as opposed to an individual window.
  • wxClientDC. Use this to paint on the client area of window (the part withoutborders and other decorations), but do not use it from within an wxPaintEvent.
  • wxPaintDC. Use this to paint on the client area of a window, but only fromwithin a wxPaintEvent.
  • wxWindowDC. Use this to paint on the whole area of a window, including decorations.This may not be available on non-Windows platforms.

To use a client, paint or window device context, create an object on the stack withthe window as argument, for example:

  void MyWindow::OnMyCmd(wxCommandEvent& event)
  {
    wxClientDC dc(window);
    DrawMyPicture(dc);
  }

Try to write code so it is parameterised by wxDC - if you do this, the same piece of code maywrite to a number of different devices, by passing a different device context. This doesn'twork for everything (for example not all device contexts support bitmap drawing) butwill work most of the time.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值