]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dcscreen.cpp
fixed SaveDIB() crash with BW images (patch 1045884)
[wxWidgets.git] / src / gtk1 / dcscreen.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcscreen.cpp
3// Purpose:
4// Author: Robert Roebling
dbf858b5 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
11#pragma implementation "dcscreen.h"
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
c801d85f
KB
17#include "wx/dcscreen.h"
18#include "wx/window.h"
dbf858b5 19
071a2d78 20#include <gdk/gdk.h>
5d25c050 21#include <gdk/gdkx.h>
071a2d78 22#include <gtk/gtk.h>
83624f79 23
dbf858b5
RR
24//-----------------------------------------------------------------------------
25// global data initialization
26//-----------------------------------------------------------------------------
27
28GdkWindow *wxScreenDC::sm_overlayWindow = (GdkWindow*) NULL;
72cdf4c9
VZ
29int wxScreenDC::sm_overlayWindowX = 0;
30int wxScreenDC::sm_overlayWindowY = 0;
dbf858b5 31
c801d85f
KB
32//-----------------------------------------------------------------------------
33// wxScreenDC
34//-----------------------------------------------------------------------------
35
36IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC)
37
72cdf4c9 38wxScreenDC::wxScreenDC()
c801d85f 39{
4bc67cc5 40 m_ok = FALSE;
4bc67cc5 41 m_cmap = gdk_colormap_get_system();
5d25c050 42 m_window = GDK_ROOT_PARENT();
72cdf4c9 43
3e3b7e75
RD
44#ifdef __WXGTK20__
45 m_context = gdk_pango_context_get();
46 m_layout = pango_layout_new( m_context );
47// m_fontdesc = pango_font_description_copy( widget->style->font_desc );
48#endif
49
e1208c31
RR
50 m_isScreenDC = TRUE;
51
4bc67cc5 52 SetUpDC();
72cdf4c9 53
4bc67cc5
RR
54 gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
55 gdk_gc_set_subwindow( m_brushGC, GDK_INCLUDE_INFERIORS );
56 gdk_gc_set_subwindow( m_textGC, GDK_INCLUDE_INFERIORS );
57 gdk_gc_set_subwindow( m_bgGC, GDK_INCLUDE_INFERIORS );
ff7b1510 58}
c801d85f 59
72cdf4c9 60wxScreenDC::~wxScreenDC()
c801d85f 61{
5d25c050
RR
62 gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
63 gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN );
64 gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN );
65 gdk_gc_set_subwindow( m_bgGC, GDK_CLIP_BY_CHILDREN );
66
4bc67cc5 67 EndDrawingOnTop();
ff7b1510 68}
c801d85f 69
dbf858b5 70bool wxScreenDC::StartDrawingOnTop( wxWindow *window )
c801d85f 71{
4bc67cc5 72 if (!window) return StartDrawingOnTop();
72cdf4c9 73
4bc67cc5
RR
74 int x = 0;
75 int y = 0;
76 window->GetPosition( &x, &y );
77 int w = 0;
78 int h = 0;
79 window->GetSize( &w, &h );
80 window->ClientToScreen( &x, &y );
72cdf4c9 81
4bc67cc5
RR
82 wxRect rect;
83 rect.x = x;
84 rect.y = y;
85 rect.width = 0;
86 rect.height = 0;
72cdf4c9 87
4bc67cc5 88 return StartDrawingOnTop( &rect );
ff7b1510 89}
c801d85f 90
16e93305 91bool wxScreenDC::StartDrawingOnTop( wxRect *rect )
c801d85f 92{
5d25c050
RR
93 int x = 0;
94 int y = 0;
95 int width = gdk_screen_width();
96 int height = gdk_screen_height();
97 if (rect)
98 {
99 x = rect->x;
100 y = rect->y;
101 width = rect->width;
102 height = rect->height;
103 }
c801d85f 104
5d25c050 105 return TRUE;
ff7b1510 106}
c801d85f 107
72cdf4c9 108bool wxScreenDC::EndDrawingOnTop()
c801d85f 109{
4bc67cc5 110 return TRUE;
ff7b1510
RR
111}
112
376aa62a
VZ
113void wxScreenDC::DoGetSize(int *width, int *height) const
114{
115 wxDisplaySize(width, height);
116}