| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: dcscreen.cpp |
| 3 | // Purpose: wxScreenDC class |
| 4 | // Author: Julian Smart, Robert Roebling |
| 5 | // Modified by: |
| 6 | // Created: 17/09/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Julian Smart, Robert Roebling |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
| 13 | #pragma implementation "dcscreen.h" |
| 14 | #endif |
| 15 | |
| 16 | #include "wx/window.h" |
| 17 | #include "wx/frame.h" |
| 18 | #include "wx/dcscreen.h" |
| 19 | #include "wx/utils.h" |
| 20 | #include "wx/app.h" |
| 21 | #include "wx/fontutil.h" |
| 22 | |
| 23 | #include "wx/x11/private.h" |
| 24 | |
| 25 | //----------------------------------------------------------------------------- |
| 26 | // global data initialization |
| 27 | //----------------------------------------------------------------------------- |
| 28 | |
| 29 | WXWindow *wxScreenDC::sm_overlayWindow = (WXWindow*) NULL; |
| 30 | int wxScreenDC::sm_overlayWindowX = 0; |
| 31 | int wxScreenDC::sm_overlayWindowY = 0; |
| 32 | |
| 33 | //----------------------------------------------------------------------------- |
| 34 | // wxScreenDC |
| 35 | //----------------------------------------------------------------------------- |
| 36 | |
| 37 | IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC) |
| 38 | |
| 39 | wxScreenDC::wxScreenDC() |
| 40 | { |
| 41 | m_ok = FALSE; |
| 42 | |
| 43 | m_display = (WXDisplay *) wxGlobalDisplay(); |
| 44 | |
| 45 | int screen = DefaultScreen( (Display*) m_display ); |
| 46 | m_cmap = (WXColormap) DefaultColormap( (Display*) m_display, screen ); |
| 47 | |
| 48 | m_window = (WXWindow) RootWindow( (Display*) m_display, screen ); |
| 49 | |
| 50 | m_isScreenDC = TRUE; |
| 51 | |
| 52 | #if wxUSE_UNICODE |
| 53 | m_context = wxTheApp->GetPangoContext(); |
| 54 | m_fontdesc = wxNORMAL_FONT->GetNativeFontInfo()->description; |
| 55 | #endif |
| 56 | |
| 57 | SetUpDC(); |
| 58 | |
| 59 | XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors ); |
| 60 | XSetSubwindowMode( (Display*) m_display, (GC) m_brushGC, IncludeInferiors ); |
| 61 | XSetSubwindowMode( (Display*) m_display, (GC) m_textGC, IncludeInferiors ); |
| 62 | XSetSubwindowMode( (Display*) m_display, (GC) m_bgGC, IncludeInferiors ); |
| 63 | } |
| 64 | |
| 65 | wxScreenDC::~wxScreenDC() |
| 66 | { |
| 67 | XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren ); |
| 68 | XSetSubwindowMode( (Display*) m_display, (GC) m_brushGC, ClipByChildren ); |
| 69 | XSetSubwindowMode( (Display*) m_display, (GC) m_textGC, ClipByChildren ); |
| 70 | XSetSubwindowMode( (Display*) m_display, (GC) m_bgGC, ClipByChildren ); |
| 71 | |
| 72 | EndDrawingOnTop(); |
| 73 | } |
| 74 | |
| 75 | bool wxScreenDC::StartDrawingOnTop( wxWindow *window ) |
| 76 | { |
| 77 | if (!window) return StartDrawingOnTop(); |
| 78 | |
| 79 | int x = 0; |
| 80 | int y = 0; |
| 81 | window->GetPosition( &x, &y ); |
| 82 | int w = 0; |
| 83 | int h = 0; |
| 84 | window->GetSize( &w, &h ); |
| 85 | window->ClientToScreen( &x, &y ); |
| 86 | |
| 87 | wxRect rect; |
| 88 | rect.x = x; |
| 89 | rect.y = y; |
| 90 | rect.width = 0; |
| 91 | rect.height = 0; |
| 92 | |
| 93 | return StartDrawingOnTop( &rect ); |
| 94 | } |
| 95 | |
| 96 | bool wxScreenDC::StartDrawingOnTop( wxRect *rectIn ) |
| 97 | { |
| 98 | // VZ: should we do the same thing that wxMotif wxScreenDC does here? |
| 99 | #if 0 |
| 100 | wxRect rect; |
| 101 | if ( rectIn ) |
| 102 | { |
| 103 | rect = *rectIn; |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | rect.x = |
| 108 | rect.y = 0; |
| 109 | |
| 110 | DoGetSize(&rect.width, &rect.height); |
| 111 | } |
| 112 | #endif // 0 |
| 113 | |
| 114 | return TRUE; |
| 115 | } |
| 116 | |
| 117 | bool wxScreenDC::EndDrawingOnTop() |
| 118 | { |
| 119 | return TRUE; |
| 120 | } |
| 121 | |
| 122 | void wxScreenDC::DoGetSize(int *width, int *height) const |
| 123 | { |
| 124 | wxDisplaySize(width, height); |
| 125 | } |