]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/dcscreen.cpp
don't crash under GTK1 if we failed to get GdkFont in GetTextExtent()
[wxWidgets.git] / src / gtk / dcscreen.cpp
... / ...
CommitLineData
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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11#pragma implementation "dcscreen.h"
12#endif
13
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
17#include "wx/dcscreen.h"
18#include "wx/window.h"
19
20#include <gdk/gdk.h>
21#include <gdk/gdkx.h>
22#include <gtk/gtk.h>
23
24//-----------------------------------------------------------------------------
25// global data initialization
26//-----------------------------------------------------------------------------
27
28GdkWindow *wxScreenDC::sm_overlayWindow = (GdkWindow*) NULL;
29int wxScreenDC::sm_overlayWindowX = 0;
30int wxScreenDC::sm_overlayWindowY = 0;
31
32//-----------------------------------------------------------------------------
33// wxScreenDC
34//-----------------------------------------------------------------------------
35
36IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC)
37
38wxScreenDC::wxScreenDC()
39{
40 m_ok = FALSE;
41 m_cmap = gdk_colormap_get_system();
42 m_window = GDK_ROOT_PARENT();
43
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
50 m_isScreenDC = TRUE;
51
52 SetUpDC();
53
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 );
58}
59
60wxScreenDC::~wxScreenDC()
61{
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
67 EndDrawingOnTop();
68}
69
70bool wxScreenDC::StartDrawingOnTop( wxWindow *window )
71{
72 if (!window) return StartDrawingOnTop();
73
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 );
81
82 wxRect rect;
83 rect.x = x;
84 rect.y = y;
85 rect.width = 0;
86 rect.height = 0;
87
88 return StartDrawingOnTop( &rect );
89}
90
91bool wxScreenDC::StartDrawingOnTop( wxRect *rect )
92{
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 }
104
105 return TRUE;
106}
107
108bool wxScreenDC::EndDrawingOnTop()
109{
110 return TRUE;
111}
112
113void wxScreenDC::DoGetSize(int *width, int *height) const
114{
115 wxDisplaySize(width, height);
116}