| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: src/motif/dc.cpp |
| 3 | // Purpose: wxDC class |
| 4 | // Author: Julian Smart |
| 5 | // Modified by: |
| 6 | // Created: 01/02/97 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Julian Smart |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | // For compilers that support precompilation, includes "wx.h". |
| 13 | #include "wx/wxprec.h" |
| 14 | |
| 15 | #include "wx/dc.h" |
| 16 | |
| 17 | #ifndef WX_PRECOMP |
| 18 | #include "wx/dcmemory.h" |
| 19 | #endif |
| 20 | |
| 21 | IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) |
| 22 | |
| 23 | //----------------------------------------------------------------------------- |
| 24 | // wxDC |
| 25 | //----------------------------------------------------------------------------- |
| 26 | |
| 27 | wxDC::wxDC() |
| 28 | { |
| 29 | m_ok = false; |
| 30 | |
| 31 | m_backgroundMode = wxTRANSPARENT; |
| 32 | |
| 33 | m_isInteractive = false; |
| 34 | } |
| 35 | |
| 36 | void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) |
| 37 | { |
| 38 | wxCHECK_RET( Ok(), "invalid dc" ); |
| 39 | wxCHECK_RET( icon.Ok(), "invalid icon" ); |
| 40 | |
| 41 | DoDrawBitmap(icon, x, y, true); |
| 42 | } |
| 43 | |
| 44 | void wxDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) |
| 45 | { |
| 46 | wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); |
| 47 | |
| 48 | wxMemoryDC memDC; |
| 49 | memDC.SelectObjectAsSource(bitmap); |
| 50 | |
| 51 | #if 0 |
| 52 | // Not sure if we need this. The mask should leave the masked areas as per |
| 53 | // the original background of this DC. |
| 54 | if (useMask) |
| 55 | { |
| 56 | // There might be transparent areas, so make these the same colour as this |
| 57 | // DC |
| 58 | memDC.SetBackground(* GetBackground()); |
| 59 | memDC.Clear(); |
| 60 | } |
| 61 | #endif // 0 |
| 62 | |
| 63 | Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask); |
| 64 | |
| 65 | memDC.SelectObject(wxNullBitmap); |
| 66 | } |
| 67 | |
| 68 | void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) |
| 69 | { |
| 70 | m_clipping = true; |
| 71 | m_clipX1 = x; |
| 72 | m_clipY1 = y; |
| 73 | m_clipX2 = x + width; |
| 74 | m_clipY2 = y + height; |
| 75 | } |
| 76 | |
| 77 | void wxDC::DoGetSize( int* width, int* height ) const |
| 78 | { |
| 79 | if ( width ) |
| 80 | *width = m_maxX - m_minX; |
| 81 | if ( height ) |
| 82 | *height = m_maxY - m_minY; |
| 83 | } |
| 84 | |
| 85 | void wxDC::DoGetSizeMM( int* width, int* height ) const |
| 86 | { |
| 87 | int w, h; |
| 88 | GetSize( &w, &h ); |
| 89 | |
| 90 | if ( width ) |
| 91 | *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) ); |
| 92 | if ( height ) |
| 93 | *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) ); |
| 94 | } |
| 95 | |
| 96 | // Resolution in pixels per logical inch |
| 97 | wxSize wxDC::GetPPI() const |
| 98 | { |
| 99 | // TODO (should probably be pure virtual) |
| 100 | return wxSize(0, 0); |
| 101 | } |