From 5d25c05039a7c6ebbddfe16d99234dc756e75356 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 3 Mar 2000 20:09:19 +0000 Subject: [PATCH] Clean-up, speed-up and bug-fix for wxListCtrl drawing, Removed overlay things from wxScreenDC, Added test for bitmaps clipping with regions. Updates to changes.txt git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6424 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/gtk/changes.txt | 27 +++- samples/drawing/drawing.cpp | 11 +- src/generic/listctrl.cpp | 154 ++++++++++---------- src/gtk/dcscreen.cpp | 280 +++--------------------------------- src/gtk1/dcscreen.cpp | 280 +++--------------------------------- 5 files changed, 142 insertions(+), 610 deletions(-) diff --git a/docs/gtk/changes.txt b/docs/gtk/changes.txt index 694e7c8572..5bb7d1c5d7 100644 --- a/docs/gtk/changes.txt +++ b/docs/gtk/changes.txt @@ -1,13 +1,29 @@ +12th March '2000: wxWindows 2.1.14 released -20th February '2000: wxWindows 2.1.14 released +Added wxDragImage class for dragging easily images. -Minor changes to socket code. +The DEB and RPM packages now conform better to various +standards. + +Renamed wx-config to wxgtk-config so that motif can be co-installed +on the same machine (with wxmotif-config). + +Speed up for drawing by resuing once created DCs instead of +creating and destroying them all the time. + +Corrections to clipping region code (among others related to +simultaneous bitmap clipping). + +A few more improvements to tab traversal. + +A number of changes to socket code. Added code for rotating images. -Much work on the new grid class has been done. +Much work on the new grid class has been done. Very cool now. -wxPlotWindow is now useful and works. +wxPlotWindow is now useful and works. Added on-off lines useful for +displaying trigger signals. Corrected one more bug in the TIFF handler. @@ -20,7 +36,8 @@ Added default keyboard handling to wxScrolledWindow. Fixed slightly overoptimized window colour and style handling. This will expose a bug in the GtkPixmap theme, or more exactly in ImLib's image cashing so that wxGTK currently doesn't work -well with pixamp themes. +well with pixmap themes. As a result, wxGTK will disable all +widget settings when using this theme. Fixed bug in drawing code that made GTK pick the wrong pen style when using the default. diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 1c67694c32..91a4cc4169 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -581,14 +581,11 @@ void MyCanvas::DrawDefault(wxDC& dc) dc.FloodFill(0, 0, wxColour(255, 0, 0)); #endif // - dc.DrawIcon( wxICON(mondrian), 40, 40 ); - dc.DrawCheckMark(5, 80, 15, 15); dc.DrawCheckMark(25, 80, 30, 30); dc.DrawCheckMark(60, 80, 60, 60); // this is the test for "blitting bitmap into DC damages selected brush" bug - wxIcon m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); wxCoord rectSize = m_std_icon.GetWidth() + 10; wxCoord x = 100; dc.SetPen(*wxTRANSPARENT_PEN); @@ -911,6 +908,14 @@ void MyCanvas::DrawRegions(wxDC& dc) dc.SetBrush( *wxGREY_BRUSH ); dc.DrawRectangle( 10,10,310,310 ); + + if (m_smile_bmp.Ok()) + { + dc.DrawBitmap( m_smile_bmp, 140, 20, TRUE ); + dc.DrawBitmap( m_smile_bmp, 140, 290, TRUE ); + dc.DrawBitmap( m_smile_bmp, 110, 80, TRUE ); + dc.DrawBitmap( m_smile_bmp, 210, 80, TRUE ); + } } void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event)) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 5ddfbf0f03..573cdd5007 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -620,15 +620,42 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing ) case wxLC_ICON: { m_bound_all.width = m_spacing; - m_bound_all.height = m_spacing+13; wxNode *node = m_items.First(); if (node) { wxListItemData *item = (wxListItemData*)node->Data(); wxString s = item->GetText(); + if (s.IsEmpty()) s = wxT("H"); wxCoord lw,lh; dc->GetTextExtent( s, &lw, &lh ); + if (lh < 15) lh = 15; + lw += 4; + lh += 3; + + m_bound_all.height = m_spacing+lh; if (lw > m_spacing) m_bound_all.width = lw; + m_bound_label.width = lw; + m_bound_label.height = lh; + + if (item->HasImage()) + { + int w = 0; + int h = 0; + m_owner->GetImageSize( item->GetImage(), w, h ); + m_bound_icon.width = w + 8; + m_bound_icon.height = h + 8; + } + + if (!item->HasText()) + { + m_bound_hilight.width = m_bound_icon.width; + m_bound_hilight.height = m_bound_icon.height; + } + else + { + m_bound_hilight.width = m_bound_label.width; + m_bound_hilight.height = m_bound_label.height; + } } break; } @@ -638,24 +665,34 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing ) if (node) { wxListItemData *item = (wxListItemData*)node->Data(); + wxString s = item->GetText(); + if (s.IsEmpty()) s = wxT("H"); wxCoord lw,lh; dc->GetTextExtent( s, &lw, &lh ); + if (lh < 15) lh = 15; + lw += 4; + lh += 3; + m_bound_label.width = lw; + m_bound_label.height = lh; + m_bound_all.width = lw; m_bound_all.height = lh; + if (item->HasImage()) { -#ifdef __WIN16__ int w = 0; int h = 0; -#else - wxCoord w = 0; - wxCoord h = 0; -#endif m_owner->GetImageSize( item->GetImage(), w, h ); + m_bound_icon.width = w; + m_bound_icon.height = h; + m_bound_all.width += 4 + w; if (h > m_bound_all.height) m_bound_all.height = h; } + + m_bound_hilight.width = m_bound_all.width; + m_bound_hilight.height = m_bound_all.height; } break; } @@ -667,12 +704,14 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing ) while (node) { wxListItemData *item = (wxListItemData*)node->Data(); - wxString s; - item->GetText( s ); - if (s.IsNull()) s = "H"; + wxString s = item->GetText(); + if (s.IsEmpty()) s = wxT("H"); wxCoord lw,lh; dc->GetTextExtent( s, &lw, &lh ); if (lh < 15) lh = 15; + lw += 4; + lh += 3; + item->SetSize( item->GetWidth(), lh ); m_bound_all.width += lw; m_bound_all.height = lh; @@ -691,63 +730,38 @@ void wxListLineData::SetPosition( wxDC *dc, int x, int y, int window_width ) { case wxLC_ICON: { - AssignRect( m_bound_icon, 0, 0, 0, 0 ); - AssignRect( m_bound_label, 0, 0, 0, 0 ); - AssignRect( m_bound_hilight, m_bound_all ); wxNode *node = m_items.First(); if (node) { wxListItemData *item = (wxListItemData*)node->Data(); if (item->HasImage()) { - wxListItemData *item = (wxListItemData*)node->Data(); - int w = 0; - int h = 0; - m_owner->GetImageSize( item->GetImage(), w, h ); - m_bound_icon.x = m_bound_all.x + (m_spacing/2) - (w/2); - m_bound_icon.y = m_bound_all.y + m_spacing - h - 5; - m_bound_icon.width = w; - m_bound_icon.height = h; - if (!item->HasText()) - { - AssignRect( m_bound_hilight, m_bound_icon ); - m_bound_hilight.x -= 5; - m_bound_hilight.y -= 5; - m_bound_hilight.width += 9; - m_bound_hilight.height += 9; - } + m_bound_icon.x = m_bound_all.x + 4 + (m_spacing/2) - (m_bound_icon.width/2); + m_bound_icon.y = m_bound_all.y + 4; } if (item->HasText()) { - wxString s; - item->GetText( s ); - wxCoord lw,lh; - dc->GetTextExtent( s, &lw, &lh ); if (m_bound_all.width > m_spacing) - m_bound_label.x = m_bound_all.x; + m_bound_label.x = m_bound_all.x + 2; else - m_bound_label.x = m_bound_all.x + (m_spacing/2) - lw/2; - m_bound_label.y = m_bound_all.y + m_bound_all.height - lh; - m_bound_label.width = lw; - m_bound_label.height = lh; - AssignRect( m_bound_hilight, m_bound_label ); - m_bound_hilight.x -= 2; - m_bound_hilight.y -= 2; - m_bound_hilight.width += 4; - m_bound_hilight.height += 4; + m_bound_label.x = m_bound_all.x + 2 + (m_spacing/2) - (m_bound_label.width/2); + m_bound_label.y = m_bound_all.y + m_bound_all.height + 2 - m_bound_label.height; + m_bound_hilight.x = m_bound_label.x - 2; + m_bound_hilight.y = m_bound_label.y - 2; + } + else + { + m_bound_hilight.x = m_bound_icon.x - 4; + m_bound_hilight.y = m_bound_icon.y - 4; } } break; } case wxLC_LIST: { - AssignRect( m_bound_label, m_bound_all ); - m_bound_all.x -= 2; - m_bound_all.y -= 2; - m_bound_all.width += 4; - m_bound_all.height += 3; - AssignRect( m_bound_hilight, m_bound_all ); - AssignRect( m_bound_icon, 0, 0, 0, 0 ); + m_bound_hilight.x = m_bound_all.x; + m_bound_hilight.y = m_bound_all.y; + m_bound_label.y = m_bound_all.y + 2; wxNode *node = m_items.First(); if (node) { @@ -756,51 +770,31 @@ void wxListLineData::SetPosition( wxDC *dc, int x, int y, int window_width ) { m_bound_icon.x = m_bound_all.x + 2; m_bound_icon.y = m_bound_all.y + 2; - int w; - int h; - m_owner->GetImageSize( item->GetImage(), w, h ); - m_bound_icon.width = w; - m_bound_icon.height = h; - m_bound_label.x += 4 + w; - m_bound_label.width -= 4 + w; + m_bound_label.x = m_bound_all.x + 6 + m_bound_icon.width; + } + else + { + m_bound_label.x = m_bound_all.x + 2; } } break; } case wxLC_REPORT: { - wxCoord lw,lh; - dc->GetTextExtent( "H", &lw, &lh ); - if (lh < 15) lh = 15; m_bound_all.x = 0; - m_bound_all.y -= 0; - m_bound_all.height = lh+3; m_bound_all.width = window_width; AssignRect( m_bound_hilight, m_bound_all ); - AssignRect( m_bound_label, m_bound_all ); - AssignRect( m_bound_icon, 0, 0, 0, 0 ); + m_bound_label.x = m_bound_all.x + 2; + m_bound_label.y = m_bound_all.y + 2; wxNode *node = m_items.First(); if (node) { wxListItemData *item = (wxListItemData*)node->Data(); - wxString s; - item->GetText( s ); - if (s.IsEmpty()) s = wxT("H"); - wxCoord lw,lh; - dc->GetTextExtent( s, &lw, &lh ); - if (lh < 15) lh = 15; - m_bound_label.width = lw; - m_bound_label.height = lh; if (item->HasImage()) { m_bound_icon.x = m_bound_all.x + 2; m_bound_icon.y = m_bound_all.y + 2; - int w; - int h; - m_owner->GetImageSize( item->GetImage(), w, h ); - m_bound_icon.width = w; - m_bound_icon.height = h; - m_bound_label.x += 4 + w; + m_bound_label.x += 4 + m_bound_icon.width; } } break; @@ -2586,7 +2580,7 @@ void wxListMainWindow::CalculatePositions() line->CalculateSize( &dc, iconSpacing ); int dummy = 0; line->GetSize( dummy, lineSpacing ); - lineSpacing += 4; + lineSpacing += 1; int clientWidth = 0; int clientHeight = 0; @@ -2643,8 +2637,8 @@ void wxListMainWindow::CalculatePositions() for (int tries = 0; tries < 2; tries++) { entireWidth = 0; - int x = 5; // painting is done at x-2 - int y = 5; // painting is done at y-2 + int x = 2; + int y = 2; int maxWidth = 0; m_visibleLines = 0; int m_currentVisibleLines = 0; diff --git a/src/gtk/dcscreen.cpp b/src/gtk/dcscreen.cpp index 33766926fd..825cd2b2de 100644 --- a/src/gtk/dcscreen.cpp +++ b/src/gtk/dcscreen.cpp @@ -15,6 +15,7 @@ #include "wx/window.h" #include +#include #include //----------------------------------------------------------------------------- @@ -25,219 +26,6 @@ GdkWindow *wxScreenDC::sm_overlayWindow = (GdkWindow*) NULL; int wxScreenDC::sm_overlayWindowX = 0; int wxScreenDC::sm_overlayWindowY = 0; -//----------------------------------------------------------------------------- -// create X window -//----------------------------------------------------------------------------- - -extern "C" { - -#include -#include -#include - -int my_nevent_masks = 17; -int my_event_masks_table[19] = -{ - ExposureMask, - PointerMotionMask, - PointerMotionHintMask, - ButtonMotionMask, - Button1MotionMask, - Button2MotionMask, - Button3MotionMask, - ButtonPressMask | OwnerGrabButtonMask, - ButtonReleaseMask | OwnerGrabButtonMask, - KeyPressMask, - KeyReleaseMask, - EnterWindowMask, - LeaveWindowMask, - FocusChangeMask, - StructureNotifyMask, - PropertyChangeMask, - VisibilityChangeMask, - 0, /* PROXIMITY_IN */ - 0 /* PROXIMTY_OUT */ -}; - -GdkWindow* -gdk_window_transparent_new ( GdkWindow *parent, - GdkWindowAttr *attributes, - gint attributes_mask) -{ - GdkWindow *window; - GdkWindowPrivate *gprivate; - GdkWindowPrivate *parent_private; - GdkVisual *visual; - Display *parent_display; - Window xparent; - Visual *xvisual; - XSetWindowAttributes xattributes; - long xattributes_mask; - XSizeHints size_hints; - XWMHints wm_hints; - XClassHint *class_hint; - int x, y, depth; - unsigned int gclass; - char *title; - int i; - - g_return_val_if_fail (attributes != NULL, NULL); - - if (!parent) - parent = (GdkWindow*) &gdk_root_parent; - - parent_private = (GdkWindowPrivate*) parent; - if (parent_private->destroyed) - return NULL; - - xparent = parent_private->xwindow; - parent_display = parent_private->xdisplay; - - gprivate = g_new (GdkWindowPrivate, 1); - window = (GdkWindow*) gprivate; - - gprivate->parent = parent; - - if (parent_private != &gdk_root_parent) - parent_private->children = g_list_prepend (parent_private->children, window); - - gprivate->xdisplay = parent_display; - gprivate->destroyed = FALSE; - gprivate->resize_count = 0; - gprivate->ref_count = 1; - xattributes_mask = 0; - - if (attributes_mask & GDK_WA_X) - x = attributes->x; - else - x = 0; - - if (attributes_mask & GDK_WA_Y) - y = attributes->y; - else - y = 0; - - gprivate->x = x; - gprivate->y = y; - gprivate->width = (attributes->width > 1) ? (attributes->width) : (1); - gprivate->height = (attributes->height > 1) ? (attributes->height) : (1); - gprivate->window_type = attributes->window_type; - gprivate->extension_events = FALSE; - -#if (GTK_MINOR_VERSION == 0) - gprivate->dnd_drag_data_type = None; - gprivate->dnd_drag_data_typesavail = - gprivate->dnd_drop_data_typesavail = NULL; - gprivate->dnd_drop_enabled = gprivate->dnd_drag_enabled = - gprivate->dnd_drag_accepted = gprivate->dnd_drag_datashow = - gprivate->dnd_drop_data_numtypesavail = - gprivate->dnd_drag_data_numtypesavail = 0; - gprivate->dnd_drag_eventmask = gprivate->dnd_drag_savedeventmask = 0; -#endif - - gprivate->filters = NULL; - gprivate->children = NULL; - - window->user_data = NULL; - - if (attributes_mask & GDK_WA_VISUAL) - visual = attributes->visual; - else - visual = gdk_visual_get_system (); - xvisual = ((GdkVisualPrivate*) visual)->xvisual; - - xattributes.event_mask = StructureNotifyMask; - for (i = 0; i < my_nevent_masks; i++) - { - if (attributes->event_mask & (1 << (i + 1))) - xattributes.event_mask |= my_event_masks_table[i]; - } - - if (xattributes.event_mask) - xattributes_mask |= CWEventMask; - - if(attributes_mask & GDK_WA_NOREDIR) { - xattributes.override_redirect = - (attributes->override_redirect == FALSE)?False:True; - xattributes_mask |= CWOverrideRedirect; - } else - xattributes.override_redirect = False; - - gclass = InputOutput; - depth = visual->depth; - - if (attributes_mask & GDK_WA_COLORMAP) - gprivate->colormap = attributes->colormap; - else - gprivate->colormap = gdk_colormap_get_system (); - - xattributes.colormap = ((GdkColormapPrivate*) gprivate->colormap)->xcolormap; - xattributes_mask |= CWColormap; - - xparent = gdk_root_window; - - xattributes.save_under = True; - xattributes.override_redirect = True; - xattributes.cursor = None; - xattributes_mask |= CWSaveUnder | CWOverrideRedirect; - - gprivate->xwindow = XCreateWindow (gprivate->xdisplay, xparent, - x, y, gprivate->width, gprivate->height, - 0, depth, gclass, xvisual, - xattributes_mask, &xattributes); - gdk_window_ref (window); - gdk_xid_table_insert (&gprivate->xwindow, window); - - if (gprivate->colormap) - gdk_colormap_ref (gprivate->colormap); - - XSetWMProtocols (gprivate->xdisplay, gprivate->xwindow, gdk_wm_window_protocols, 2); - - size_hints.flags = PSize; - size_hints.width = gprivate->width; - size_hints.height = gprivate->height; - - wm_hints.flags = InputHint | StateHint | WindowGroupHint; - wm_hints.window_group = gdk_leader_window; - wm_hints.input = True; - wm_hints.initial_state = NormalState; - - /* FIXME: Is there any point in doing this? Do any WM's pay - * attention to PSize, and even if they do, is this the - * correct value??? - */ - XSetWMNormalHints (gprivate->xdisplay, gprivate->xwindow, &size_hints); - - XSetWMHints (gprivate->xdisplay, gprivate->xwindow, &wm_hints); - - if (attributes_mask & GDK_WA_TITLE) - title = attributes->title; - else -#if (GTK_MINOR_VERSION > 0) - title = "Unknown"; // GLH: Well I don't know for the moment what to write here. -#else - title = gdk_progname; -#endif - - XmbSetWMProperties (gprivate->xdisplay, gprivate->xwindow, - title, title, - NULL, 0, - NULL, NULL, NULL); - - if (attributes_mask & GDK_WA_WMCLASS) - { - class_hint = XAllocClassHint (); - class_hint->res_name = attributes->wmclass_name; - class_hint->res_class = attributes->wmclass_class; - XSetClassHint (gprivate->xdisplay, gprivate->xwindow, class_hint); - XFree (class_hint); - } - - return window; -} - -} // extern "C" - //----------------------------------------------------------------------------- // wxScreenDC //----------------------------------------------------------------------------- @@ -247,19 +35,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC) wxScreenDC::wxScreenDC() { m_ok = FALSE; - m_window = (GdkWindow *) NULL; m_cmap = gdk_colormap_get_system(); - - if (sm_overlayWindow) - { - m_window = sm_overlayWindow; - m_deviceOriginX = - sm_overlayWindowX; - m_deviceOriginY = - sm_overlayWindowY; - } - else - { - m_window = GDK_ROOT_PARENT(); - } + m_window = GDK_ROOT_PARENT(); SetUpDC(); @@ -271,6 +48,11 @@ wxScreenDC::wxScreenDC() wxScreenDC::~wxScreenDC() { + gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_bgGC, GDK_CLIP_BY_CHILDREN ); + EndDrawingOnTop(); } @@ -297,47 +79,23 @@ bool wxScreenDC::StartDrawingOnTop( wxWindow *window ) bool wxScreenDC::StartDrawingOnTop( wxRect *rect ) { - int x = 0; - int y = 0; - int width = gdk_screen_width(); - int height = gdk_screen_height(); - if (rect) - { - x = rect->x; - y = rect->y; - width = rect->width; - height = rect->height; - } - - sm_overlayWindowX = x; - sm_overlayWindowY = y; - - GdkWindowAttr attr; - attr.x = x; - attr.y = y; - attr.width = width; - attr.height = height; - attr.override_redirect = TRUE; - attr.wclass = GDK_INPUT_OUTPUT; - attr.event_mask = 0; - attr.window_type = GDK_WINDOW_TEMP; - - // GTK cannot set transparent backgrounds. :-( - sm_overlayWindow = gdk_window_transparent_new( NULL, &attr, GDK_WA_NOREDIR | GDK_WA_X | GDK_WA_Y ); - - if (sm_overlayWindow) gdk_window_show( sm_overlayWindow ); + int x = 0; + int y = 0; + int width = gdk_screen_width(); + int height = gdk_screen_height(); + if (rect) + { + x = rect->x; + y = rect->y; + width = rect->width; + height = rect->height; + } - return (sm_overlayWindow != NULL); + return TRUE; } bool wxScreenDC::EndDrawingOnTop() { - if (sm_overlayWindow) gdk_window_destroy( sm_overlayWindow ); - - sm_overlayWindow = NULL; - sm_overlayWindowX = 0; - sm_overlayWindowY = 0; - return TRUE; } diff --git a/src/gtk1/dcscreen.cpp b/src/gtk1/dcscreen.cpp index 33766926fd..825cd2b2de 100644 --- a/src/gtk1/dcscreen.cpp +++ b/src/gtk1/dcscreen.cpp @@ -15,6 +15,7 @@ #include "wx/window.h" #include +#include #include //----------------------------------------------------------------------------- @@ -25,219 +26,6 @@ GdkWindow *wxScreenDC::sm_overlayWindow = (GdkWindow*) NULL; int wxScreenDC::sm_overlayWindowX = 0; int wxScreenDC::sm_overlayWindowY = 0; -//----------------------------------------------------------------------------- -// create X window -//----------------------------------------------------------------------------- - -extern "C" { - -#include -#include -#include - -int my_nevent_masks = 17; -int my_event_masks_table[19] = -{ - ExposureMask, - PointerMotionMask, - PointerMotionHintMask, - ButtonMotionMask, - Button1MotionMask, - Button2MotionMask, - Button3MotionMask, - ButtonPressMask | OwnerGrabButtonMask, - ButtonReleaseMask | OwnerGrabButtonMask, - KeyPressMask, - KeyReleaseMask, - EnterWindowMask, - LeaveWindowMask, - FocusChangeMask, - StructureNotifyMask, - PropertyChangeMask, - VisibilityChangeMask, - 0, /* PROXIMITY_IN */ - 0 /* PROXIMTY_OUT */ -}; - -GdkWindow* -gdk_window_transparent_new ( GdkWindow *parent, - GdkWindowAttr *attributes, - gint attributes_mask) -{ - GdkWindow *window; - GdkWindowPrivate *gprivate; - GdkWindowPrivate *parent_private; - GdkVisual *visual; - Display *parent_display; - Window xparent; - Visual *xvisual; - XSetWindowAttributes xattributes; - long xattributes_mask; - XSizeHints size_hints; - XWMHints wm_hints; - XClassHint *class_hint; - int x, y, depth; - unsigned int gclass; - char *title; - int i; - - g_return_val_if_fail (attributes != NULL, NULL); - - if (!parent) - parent = (GdkWindow*) &gdk_root_parent; - - parent_private = (GdkWindowPrivate*) parent; - if (parent_private->destroyed) - return NULL; - - xparent = parent_private->xwindow; - parent_display = parent_private->xdisplay; - - gprivate = g_new (GdkWindowPrivate, 1); - window = (GdkWindow*) gprivate; - - gprivate->parent = parent; - - if (parent_private != &gdk_root_parent) - parent_private->children = g_list_prepend (parent_private->children, window); - - gprivate->xdisplay = parent_display; - gprivate->destroyed = FALSE; - gprivate->resize_count = 0; - gprivate->ref_count = 1; - xattributes_mask = 0; - - if (attributes_mask & GDK_WA_X) - x = attributes->x; - else - x = 0; - - if (attributes_mask & GDK_WA_Y) - y = attributes->y; - else - y = 0; - - gprivate->x = x; - gprivate->y = y; - gprivate->width = (attributes->width > 1) ? (attributes->width) : (1); - gprivate->height = (attributes->height > 1) ? (attributes->height) : (1); - gprivate->window_type = attributes->window_type; - gprivate->extension_events = FALSE; - -#if (GTK_MINOR_VERSION == 0) - gprivate->dnd_drag_data_type = None; - gprivate->dnd_drag_data_typesavail = - gprivate->dnd_drop_data_typesavail = NULL; - gprivate->dnd_drop_enabled = gprivate->dnd_drag_enabled = - gprivate->dnd_drag_accepted = gprivate->dnd_drag_datashow = - gprivate->dnd_drop_data_numtypesavail = - gprivate->dnd_drag_data_numtypesavail = 0; - gprivate->dnd_drag_eventmask = gprivate->dnd_drag_savedeventmask = 0; -#endif - - gprivate->filters = NULL; - gprivate->children = NULL; - - window->user_data = NULL; - - if (attributes_mask & GDK_WA_VISUAL) - visual = attributes->visual; - else - visual = gdk_visual_get_system (); - xvisual = ((GdkVisualPrivate*) visual)->xvisual; - - xattributes.event_mask = StructureNotifyMask; - for (i = 0; i < my_nevent_masks; i++) - { - if (attributes->event_mask & (1 << (i + 1))) - xattributes.event_mask |= my_event_masks_table[i]; - } - - if (xattributes.event_mask) - xattributes_mask |= CWEventMask; - - if(attributes_mask & GDK_WA_NOREDIR) { - xattributes.override_redirect = - (attributes->override_redirect == FALSE)?False:True; - xattributes_mask |= CWOverrideRedirect; - } else - xattributes.override_redirect = False; - - gclass = InputOutput; - depth = visual->depth; - - if (attributes_mask & GDK_WA_COLORMAP) - gprivate->colormap = attributes->colormap; - else - gprivate->colormap = gdk_colormap_get_system (); - - xattributes.colormap = ((GdkColormapPrivate*) gprivate->colormap)->xcolormap; - xattributes_mask |= CWColormap; - - xparent = gdk_root_window; - - xattributes.save_under = True; - xattributes.override_redirect = True; - xattributes.cursor = None; - xattributes_mask |= CWSaveUnder | CWOverrideRedirect; - - gprivate->xwindow = XCreateWindow (gprivate->xdisplay, xparent, - x, y, gprivate->width, gprivate->height, - 0, depth, gclass, xvisual, - xattributes_mask, &xattributes); - gdk_window_ref (window); - gdk_xid_table_insert (&gprivate->xwindow, window); - - if (gprivate->colormap) - gdk_colormap_ref (gprivate->colormap); - - XSetWMProtocols (gprivate->xdisplay, gprivate->xwindow, gdk_wm_window_protocols, 2); - - size_hints.flags = PSize; - size_hints.width = gprivate->width; - size_hints.height = gprivate->height; - - wm_hints.flags = InputHint | StateHint | WindowGroupHint; - wm_hints.window_group = gdk_leader_window; - wm_hints.input = True; - wm_hints.initial_state = NormalState; - - /* FIXME: Is there any point in doing this? Do any WM's pay - * attention to PSize, and even if they do, is this the - * correct value??? - */ - XSetWMNormalHints (gprivate->xdisplay, gprivate->xwindow, &size_hints); - - XSetWMHints (gprivate->xdisplay, gprivate->xwindow, &wm_hints); - - if (attributes_mask & GDK_WA_TITLE) - title = attributes->title; - else -#if (GTK_MINOR_VERSION > 0) - title = "Unknown"; // GLH: Well I don't know for the moment what to write here. -#else - title = gdk_progname; -#endif - - XmbSetWMProperties (gprivate->xdisplay, gprivate->xwindow, - title, title, - NULL, 0, - NULL, NULL, NULL); - - if (attributes_mask & GDK_WA_WMCLASS) - { - class_hint = XAllocClassHint (); - class_hint->res_name = attributes->wmclass_name; - class_hint->res_class = attributes->wmclass_class; - XSetClassHint (gprivate->xdisplay, gprivate->xwindow, class_hint); - XFree (class_hint); - } - - return window; -} - -} // extern "C" - //----------------------------------------------------------------------------- // wxScreenDC //----------------------------------------------------------------------------- @@ -247,19 +35,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC) wxScreenDC::wxScreenDC() { m_ok = FALSE; - m_window = (GdkWindow *) NULL; m_cmap = gdk_colormap_get_system(); - - if (sm_overlayWindow) - { - m_window = sm_overlayWindow; - m_deviceOriginX = - sm_overlayWindowX; - m_deviceOriginY = - sm_overlayWindowY; - } - else - { - m_window = GDK_ROOT_PARENT(); - } + m_window = GDK_ROOT_PARENT(); SetUpDC(); @@ -271,6 +48,11 @@ wxScreenDC::wxScreenDC() wxScreenDC::~wxScreenDC() { + gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN ); + gdk_gc_set_subwindow( m_bgGC, GDK_CLIP_BY_CHILDREN ); + EndDrawingOnTop(); } @@ -297,47 +79,23 @@ bool wxScreenDC::StartDrawingOnTop( wxWindow *window ) bool wxScreenDC::StartDrawingOnTop( wxRect *rect ) { - int x = 0; - int y = 0; - int width = gdk_screen_width(); - int height = gdk_screen_height(); - if (rect) - { - x = rect->x; - y = rect->y; - width = rect->width; - height = rect->height; - } - - sm_overlayWindowX = x; - sm_overlayWindowY = y; - - GdkWindowAttr attr; - attr.x = x; - attr.y = y; - attr.width = width; - attr.height = height; - attr.override_redirect = TRUE; - attr.wclass = GDK_INPUT_OUTPUT; - attr.event_mask = 0; - attr.window_type = GDK_WINDOW_TEMP; - - // GTK cannot set transparent backgrounds. :-( - sm_overlayWindow = gdk_window_transparent_new( NULL, &attr, GDK_WA_NOREDIR | GDK_WA_X | GDK_WA_Y ); - - if (sm_overlayWindow) gdk_window_show( sm_overlayWindow ); + int x = 0; + int y = 0; + int width = gdk_screen_width(); + int height = gdk_screen_height(); + if (rect) + { + x = rect->x; + y = rect->y; + width = rect->width; + height = rect->height; + } - return (sm_overlayWindow != NULL); + return TRUE; } bool wxScreenDC::EndDrawingOnTop() { - if (sm_overlayWindow) gdk_window_destroy( sm_overlayWindow ); - - sm_overlayWindow = NULL; - sm_overlayWindowX = 0; - sm_overlayWindowY = 0; - return TRUE; } -- 2.47.2