X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bc797f4cc8ffe36277ba8b7dd4b57e63a96bfcb5..a766986f6d443ba1d50e3af25f3306fa56e4518e:/src/x11/dcscreen.cpp diff --git a/src/x11/dcscreen.cpp b/src/x11/dcscreen.cpp index 3be136b3c5..7eff9560cd 100644 --- a/src/x11/dcscreen.cpp +++ b/src/x11/dcscreen.cpp @@ -1,134 +1,73 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dcscreen.cpp +// Name: src/x11/dcscreen.cpp // Purpose: wxScreenDC class -// Author: Julian Smart +// Author: Julian Smart, Robert Roebling // Modified by: // Created: 17/09/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Copyright: (c) Julian Smart, Robert Roebling +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "dcscreen.h" -#endif +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" -#include "wx/window.h" -#include "wx/frame.h" #include "wx/dcscreen.h" -#include "wx/utils.h" +#include "wx/x11/dcscreen.h" -#ifdef __VMS__ -#pragma message disable nosimpint +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/window.h" + #include "wx/frame.h" #endif -#ifdef __VMS__ -#pragma message enable nosimpint -#endif +#include "wx/fontutil.h" #include "wx/x11/private.h" -IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) +//----------------------------------------------------------------------------- +// wxScreenDC +//----------------------------------------------------------------------------- -WXWindow wxScreenDC::sm_overlayWindow = 0; -int wxScreenDC::sm_overlayWindowX = 0; -int wxScreenDC::sm_overlayWindowY = 0; +IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl,wxPaintDCImpl) -// Create a DC representing the whole screen -wxScreenDC::wxScreenDC() +wxScreenDCImpl::wxScreenDCImpl( wxDC* owner ) + : wxPaintDCImpl( owner ) { - m_display = wxGetDisplay(); - Display* display = (Display*) m_display; - - if (sm_overlayWindow) - { - m_pixmap = sm_overlayWindow; - m_deviceOriginX = - sm_overlayWindowX; - m_deviceOriginY = - sm_overlayWindowY; - } - else - m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display)); - - XGCValues gcvalues; - gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); - gcvalues.background = WhitePixel (display, DefaultScreen (display)); - gcvalues.graphics_exposures = False; - gcvalues.subwindow_mode = IncludeInferiors; - gcvalues.line_width = 1; - m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)), - GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, - &gcvalues); - - m_backgroundPixel = (int) gcvalues.background; - m_ok = TRUE; -} + m_ok = false; -wxScreenDC::~wxScreenDC() -{ - EndDrawingOnTop(); -} + m_display = (WXDisplay *) wxGlobalDisplay(); -bool wxScreenDC::StartDrawingOnTop(wxWindow* window) -{ - wxRect rect; - int x, y, width, height; - window->GetPosition(& x, & y); - if (window->GetParent() && !window->IsKindOf(CLASSINFO(wxFrame))) - window->GetParent()->ClientToScreen(& x, & y); - window->GetSize(& width, & height); - rect.x = x; rect.y = y; - rect.width = width; rect.height = height; - - return StartDrawingOnTop(& rect); + int screen = DefaultScreen( (Display*) m_display ); + m_cmap = (WXColormap) DefaultColormap( (Display*) m_display, screen ); + + m_x11window = (WXWindow) RootWindow( (Display*) m_display, screen ); + + m_isScreenDC = true; + +#if wxUSE_UNICODE + m_context = wxTheApp->GetPangoContext(); + m_fontdesc = wxNORMAL_FONT->GetNativeFontInfo()->description; +#endif + + SetUpDC(); + + XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors ); + XSetSubwindowMode( (Display*) m_display, (GC) m_brushGC, IncludeInferiors ); + XSetSubwindowMode( (Display*) m_display, (GC) m_textGC, IncludeInferiors ); + XSetSubwindowMode( (Display*) m_display, (GC) m_bgGC, IncludeInferiors ); } -bool wxScreenDC::StartDrawingOnTop(wxRect* rect) +wxScreenDCImpl::~wxScreenDCImpl() { - if (sm_overlayWindow) - return FALSE; - - Display *dpy = (Display*) wxGetDisplay(); - Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy)); - - int x = 0; - int y = 0; - int width, height; - wxDisplaySize(&width, &height); - - if (rect) - { - x = rect->x; y = rect->y; - width = rect->width; height = rect->height; - } - sm_overlayWindowX = x; - sm_overlayWindowY = y; - - XSetWindowAttributes attributes; - attributes.override_redirect = True; - unsigned long valueMask = CWOverrideRedirect; - - sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0, - wxDisplayDepth(), InputOutput, - DefaultVisual(dpy, 0), valueMask, - & attributes); - - if (sm_overlayWindow) - { - XMapWindow(dpy, (Window) sm_overlayWindow); - return TRUE; - } - else - return FALSE; + XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren ); + XSetSubwindowMode( (Display*) m_display, (GC) m_brushGC, ClipByChildren ); + XSetSubwindowMode( (Display*) m_display, (GC) m_textGC, ClipByChildren ); + XSetSubwindowMode( (Display*) m_display, (GC) m_bgGC, ClipByChildren ); } -bool wxScreenDC::EndDrawingOnTop() +void wxScreenDCImpl::DoGetSize(int *width, int *height) const { - if (sm_overlayWindow) - { - XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow); - sm_overlayWindow = 0; - return TRUE; - } - else - return FALSE; + wxDisplaySize(width, height); }