Clean-up, speed-up and bug-fix for wxListCtrl drawing,
[wxWidgets.git] / src / gtk1 / dcscreen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcscreen.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "dcscreen.h"
12 #endif
13
14 #include "wx/dcscreen.h"
15 #include "wx/window.h"
16
17 #include <gdk/gdk.h>
18 #include <gdk/gdkx.h>
19 #include <gtk/gtk.h>
20
21 //-----------------------------------------------------------------------------
22 // global data initialization
23 //-----------------------------------------------------------------------------
24
25 GdkWindow *wxScreenDC::sm_overlayWindow = (GdkWindow*) NULL;
26 int wxScreenDC::sm_overlayWindowX = 0;
27 int wxScreenDC::sm_overlayWindowY = 0;
28
29 //-----------------------------------------------------------------------------
30 // wxScreenDC
31 //-----------------------------------------------------------------------------
32
33 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC)
34
35 wxScreenDC::wxScreenDC()
36 {
37 m_ok = FALSE;
38 m_cmap = gdk_colormap_get_system();
39 m_window = GDK_ROOT_PARENT();
40
41 SetUpDC();
42
43 gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
44 gdk_gc_set_subwindow( m_brushGC, GDK_INCLUDE_INFERIORS );
45 gdk_gc_set_subwindow( m_textGC, GDK_INCLUDE_INFERIORS );
46 gdk_gc_set_subwindow( m_bgGC, GDK_INCLUDE_INFERIORS );
47 }
48
49 wxScreenDC::~wxScreenDC()
50 {
51 gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
52 gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN );
53 gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN );
54 gdk_gc_set_subwindow( m_bgGC, GDK_CLIP_BY_CHILDREN );
55
56 EndDrawingOnTop();
57 }
58
59 bool wxScreenDC::StartDrawingOnTop( wxWindow *window )
60 {
61 if (!window) return StartDrawingOnTop();
62
63 int x = 0;
64 int y = 0;
65 window->GetPosition( &x, &y );
66 int w = 0;
67 int h = 0;
68 window->GetSize( &w, &h );
69 window->ClientToScreen( &x, &y );
70
71 wxRect rect;
72 rect.x = x;
73 rect.y = y;
74 rect.width = 0;
75 rect.height = 0;
76
77 return StartDrawingOnTop( &rect );
78 }
79
80 bool wxScreenDC::StartDrawingOnTop( wxRect *rect )
81 {
82 int x = 0;
83 int y = 0;
84 int width = gdk_screen_width();
85 int height = gdk_screen_height();
86 if (rect)
87 {
88 x = rect->x;
89 y = rect->y;
90 width = rect->width;
91 height = rect->height;
92 }
93
94 return TRUE;
95 }
96
97 bool wxScreenDC::EndDrawingOnTop()
98 {
99 return TRUE;
100 }
101