InterviewSolution
| 1. |
What's The Difference Between All The Dc Types? |
|
Answer» wxPaintDC can only be used inside a EVT_PAINT event and has extra info about what regions of the window have been damaged and need to be refreshed, allowing some optimization of the re-draw. You can also use this INFORMATION to optimize your redraw if you want. wxClientDC can be used anytime for DRAWING to the window, but you must ensure that whatever you draw then is also redrawn in a EVT_PAINT event otherwise it will get lost the next time the window is refreshed. This is useful if you want to update the screen as a result of some other action, and can be used to display animations, etc. wxMemoryDC allows you to draw to a wxBitmap instead of to a window. The resulting wxBitmap can be used for a variety of things, including an off screen buffer of what is on screen. wxBufferedDC and wxBufferedPaintDC are simple convenience classes that derive from wxMemoryDC. You give it a buffer BITMAP and then all drawing goes to the bitmap. When the last reference to the buffered dc goes out of scope or is deleted then the contents of the bitmap are dumped to the real DC (if any) that you gave to the buffered dc when you constructed it. This helps to reduce flicker and such for complex drawings. and also reduces the time needed for EVT_PAINT handlers because all they are doing is drawing the buffer bitmap, not a WHOLE complex drawing. You can EASILY do the same thing yourself without the buffered DCs with just a wxMemoryDC, a bitmap and a DrawBitmap call. wxPaintDC can only be used inside a EVT_PAINT event and has extra info about what regions of the window have been damaged and need to be refreshed, allowing some optimization of the re-draw. You can also use this information to optimize your redraw if you want. wxClientDC can be used anytime for drawing to the window, but you must ensure that whatever you draw then is also redrawn in a EVT_PAINT event otherwise it will get lost the next time the window is refreshed. This is useful if you want to update the screen as a result of some other action, and can be used to display animations, etc. wxMemoryDC allows you to draw to a wxBitmap instead of to a window. The resulting wxBitmap can be used for a variety of things, including an off screen buffer of what is on screen. wxBufferedDC and wxBufferedPaintDC are simple convenience classes that derive from wxMemoryDC. You give it a buffer bitmap and then all drawing goes to the bitmap. When the last reference to the buffered dc goes out of scope or is deleted then the contents of the bitmap are dumped to the real DC (if any) that you gave to the buffered dc when you constructed it. This helps to reduce flicker and such for complex drawings. and also reduces the time needed for EVT_PAINT handlers because all they are doing is drawing the buffer bitmap, not a whole complex drawing. You can easily do the same thing yourself without the buffered DCs with just a wxMemoryDC, a bitmap and a DrawBitmap call. |
|