]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/dcclient.cpp
Stop the ApplicationShell from being managed (and thus show
[wxWidgets.git] / src / motif / dcclient.cpp
index de005e664d7d04b9f3095459c34ed39a7240def8..d702b6d7646dd990895831a8407f88b924e47b0f 100644 (file)
@@ -126,7 +126,7 @@ static int roundmin(double a, double b)
 // wxWindowDC
 // ----------------------------------------------------------------------------
 
-wxWindowDC::wxWindowDC()
+void wxWindowDC::Init()
 {
     m_gc = (WXGC) 0;
     m_gcBacking = (WXGC) 0;
@@ -138,7 +138,6 @@ wxWindowDC::wxWindowDC()
     m_currentPenDash = (wxX11Dash*) NULL;
     m_currentStyle = -1;
     m_currentFill = -1;
-    //    m_currentBkMode = wxTRANSPARENT;
     m_colour = wxColourDisplay();
     m_display = (WXDisplay*) NULL;
     m_currentRegion = (WXRegion) 0;
@@ -146,29 +145,23 @@ wxWindowDC::wxWindowDC()
     m_pixmap = (WXPixmap) 0;
     m_autoSetting = 0;
     m_oldFont = (WXFont) 0;
+    m_ok = false;
+}
+
+wxWindowDC::wxWindowDC()
+{
+    Init();
 }
 
 wxWindowDC::wxWindowDC( wxWindow *window )
 {
     wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." );
 
+    Init();
+
     m_window = window;
     m_font = window->GetFont();
-    m_gc = (WXGC) 0;
-    m_gcBacking = (WXGC) 0;
-    m_backgroundPixel = -1;
-    m_currentPenWidth = 1;
-    m_currentPenJoin = -1;
-    m_currentPenDashCount = -1;
-    m_currentPenDash = (wxX11Dash*) NULL;
-    m_currentStyle = -1;
-    m_currentFill = -1;
-    //    m_currentBkMode = wxTRANSPARENT;
-    m_colour = wxColourDisplay();
-    m_currentRegion = (WXRegion) 0;
-    m_userRegion = (WXRegion) 0;
     m_ok = TRUE;
-    m_autoSetting = 0;
 
     m_display = window->GetXDisplay();
     m_pixmap = window->GetXWindow();
@@ -260,8 +253,6 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
 
     int x1d, y1d, x2d, y2d;
 
-    //  FreeGetPixelCache();
-
     x1d = XLOG2DEV(x1);
     y1d = YLOG2DEV(y1);
     x2d = XLOG2DEV(x2);
@@ -314,8 +305,6 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    //  FreeGetPixelCache();
-
     int xx1 = XLOG2DEV (x1);
     int yy1 = YLOG2DEV (y1);
     int xx2 = XLOG2DEV (x2);
@@ -442,8 +431,6 @@ void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y )
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    //  FreeGetPixelCache();
-
     if (m_pen.Ok() && m_autoSetting)
         SetPen (m_pen);
 
@@ -458,8 +445,6 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    //  FreeGetPixelCache();
-
     if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
     {
         if (m_autoSetting)
@@ -493,8 +478,6 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[],
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    //  FreeGetPixelCache();
-
     XPoint *xpoints1 = new XPoint[n + 1];
     XPoint *xpoints2 = new XPoint[n + 1];
     int i;
@@ -546,8 +529,6 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    //  FreeGetPixelCache();
-
     int xd, yd, wfd, hfd, wd, hd;
 
     xd = XLOG2DEV(x);
@@ -591,8 +572,6 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    //  FreeGetPixelCache();
-
     // If radius is negative, it's a proportion of the smaller dimension.
 
     if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
@@ -747,8 +726,6 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx
     }
     CalcBoundingBox (x, y);
     CalcBoundingBox (x + width, y + height);
-
-
 }
 
 void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
@@ -768,8 +745,6 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei
         width = - width ;
     }
 
-    //  FreeGetPixelCache();
-
     static const int angle = 23040;
 
     int xd, yd, wd, hd;
@@ -813,66 +788,6 @@ bool wxWindowDC::CanDrawBitmap() const
     return TRUE;
 }
 
-#if 0
-void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
-{
-    //  FreeGetPixelCache();
-
-    // Be sure that foreground pixels (1) of
-    // the Icon will be painted with pen colour. [m_pen.SetColour()]
-    // Background pixels (0) will be painted with
-    // last selected background color. [::SetBackground]
-    if (m_pen.Ok() && m_autoSetting)
-        SetPen (m_pen);
-
-    int width, height;
-    Pixmap iconPixmap = (Pixmap) icon.GetPixmap();
-    width = icon.GetWidth();
-    height = icon.GetHeight();
-    if (icon.GetDisplay() == m_display)
-    {
-        if (icon.GetDepth() <= 1)
-        {
-            XCopyPlane  ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
-                0, 0, width, height,
-                (int) XLOG2DEV (x), (int) YLOG2DEV (y), 1);
-        }
-        else
-        {
-            XCopyArea  ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
-                0, 0, width, height,
-                (int) XLOG2DEV (x), (int) YLOG2DEV (y));
-        }
-
-
-        if (m_window && m_window->GetBackingPixmap())
-        {
-            if (icon.GetDepth() <= 1)
-            {
-                XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
-                    0, 0, width, height, (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), 1);
-            }
-            else
-            {
-                XCopyArea  ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
-                    0, 0, width, height,
-                    (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y));
-            }
-        }
-    } else { /* Remote copy (different (Display*) m_displays) */
-        XImage *cache = NULL;
-        if (m_window && m_window->GetBackingPixmap())
-            XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),
-            (GC) m_gcBacking, 0, 0, width, height,
-            (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), TRUE, &cache);
-        XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
-            0, 0, width, height,
-            (int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache);
-    }
-    CalcBoundingBox (x, y);
-}
-#endif // 0
-
 // TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities
 bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
                          wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask,
@@ -884,8 +799,6 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
 
     wxASSERT_MSG( sourceDC, "Blit source DC must be wxWindowDC or derived class." );
 
-    //  FreeGetPixelCache();
-
     // Be sure that foreground pixels (1) of the Icon will be painted with
     // foreground colour. [m_textForegroundColour] Background pixels (0)
     // will be painted with backgound colour (m_textBackgroundColour)
@@ -941,7 +854,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
         wxImage image = bitmap.ConvertToImage();
         if (!image.Ok())
         {
-            sourcePixmap = (Pixmap) bitmap.GetPixmap();
+            sourcePixmap = (Pixmap) bitmap.GetDrawable();
         }
         else
         {
@@ -950,7 +863,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
 
             image = image.Scale(scaledW, scaledH);
             scaledBitmap = new wxBitmap(image);
-            sourcePixmap = (Pixmap) scaledBitmap->GetPixmap();
+            sourcePixmap = (Pixmap) scaledBitmap->GetDrawable();
         }
     }
     else
@@ -982,9 +895,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
             {
                 wxMemoryDC *memDC = (wxMemoryDC *)source;
                 wxBitmap& sel = memDC->GetBitmap();
-                if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+                if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetBitmap() )
                 {
-                    XSetClipMask   ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
+                    XSetClipMask   ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetBitmap());
                     XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
                 }
             }
@@ -1033,9 +946,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
             {
                 wxMemoryDC *memDC = (wxMemoryDC *)source;
                 wxBitmap& sel = memDC->GetBitmap();
-                if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+                if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetBitmap() )
                 {
-                    XSetClipMask   ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
+                    XSetClipMask   ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetBitmap());
                     XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
                 }
             }
@@ -1482,42 +1395,31 @@ wxCoord wxWindowDC::GetCharHeight() const
     return XDEV2LOGREL(ascent + descent);
 }
 
-void wxWindowDC::Clear()
+void wxWindowDC::DoGetSize( int *width, int *height ) const
 {
-    wxCHECK_RET( Ok(), "invalid dc" );
+    int w = 0, h = 0;
 
-    int w, h;
-    if (m_window)
+    if( m_window )
     {
-        m_window->GetSize(&w, &h);
-
-        if (m_window && m_window->GetBackingPixmap())
+        if( m_window->GetBackingPixmap() )
         {
             w = m_window->GetPixmapWidth();
             h = m_window->GetPixmapHeight();
         }
-    }
-    else
-    {
-        if (this->IsKindOf(CLASSINFO(wxMemoryDC)))
-        {
-            wxMemoryDC* memDC = (wxMemoryDC*) this;
-            w = memDC->GetBitmap().GetWidth();
-            h = memDC->GetBitmap().GetHeight();
-        }
         else
-            return;
+            m_window->GetSize( &w, &h );
     }
 
-    wxBrush saveBrush = m_brush;
-    SetBrush (m_backgroundBrush);
-
-    XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, 0, w, h);
+    if( width ) *width = w;
+    if( height ) *height = h;
+}
 
-    if (m_window && m_window->GetBackingPixmap())
-        XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, 0, 0, w, h);
+void wxWindowDC::Clear()
+{
+    wxCHECK_RET( Ok(), "invalid dc" );
 
-    m_brush = saveBrush;
+    wxRect rect( wxPoint( 0, 0 ), GetSize() );
+    Clear( rect );
 }
 
 void wxWindowDC::Clear(const wxRect& rect)
@@ -1530,10 +1432,13 @@ void wxWindowDC::Clear(const wxRect& rect)
     wxBrush saveBrush = m_brush;
     SetBrush (m_backgroundBrush);
 
-    XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x, y, w, h);
+    XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc,
+                    x, y, w, h);
 
     if (m_window && m_window->GetBackingPixmap())
-        XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, x, y, w, h);
+        XFillRectangle ((Display*) m_display,
+                        (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+                        x, y, w, h);
 
     m_brush = saveBrush;
 }
@@ -1843,10 +1748,10 @@ void wxWindowDC::SetPen( const wxPen &pen )
     else if (m_currentStipple.Ok()
         && ((m_currentStipple != oldStipple) || !GetOptimization()))
     {
-        XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
+        XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetDrawable());
 
         if (m_window && m_window->GetBackingPixmap())
-            XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
+            XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetDrawable());
     }
 
     if ((m_currentFill != oldFill) || !GetOptimization())
@@ -2017,18 +1922,18 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
         if (m_currentStipple.GetDepth() == 1)
         {
             XSetStipple ((Display*) m_display, (GC) m_gc,
-                         (Pixmap) m_currentStipple.GetPixmap());
+                         (Pixmap) m_currentStipple.GetDrawable());
         if (m_window && m_window->GetBackingPixmap())
                 XSetStipple ((Display*) m_display,(GC) m_gcBacking,
-                             (Pixmap) m_currentStipple.GetPixmap());
+                             (Pixmap) m_currentStipple.GetDrawable());
         }
         else
         {
             XSetTile ((Display*) m_display, (GC) m_gc,
-                      (Pixmap) m_currentStipple.GetPixmap());
+                      (Pixmap) m_currentStipple.GetDrawable());
             if (m_window && m_window->GetBackingPixmap())
                 XSetTile ((Display*) m_display,(GC) m_gcBacking,
-                          (Pixmap) m_currentStipple.GetPixmap());
+                          (Pixmap) m_currentStipple.GetDrawable());
         }
     }
 
@@ -2055,14 +1960,6 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
 
     m_backgroundPixel = m_backgroundBrush.GetColour().AllocColour(m_display);
 
-    // New behaviour, 10/2/99: setting the background brush of a DC
-    // doesn't affect the window background colour.
-/*
-    // XSetWindowBackground doesn't work for non-Window pixmaps
-    if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
-        XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
-*/
-
     // Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
     // And Blit,... (Any fct that use XCopyPlane, in fact.)
     XSetBackground ((Display*) m_display, (GC) m_gc, m_backgroundPixel);
@@ -2150,23 +2047,14 @@ void wxWindowDC::SetTextForeground( const wxColour &col )
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    if (m_textForegroundColour == col)
-        return;
-
     m_textForegroundColour = col;
-
 }
 
 void wxWindowDC::SetTextBackground( const wxColour &col )
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
-    if (m_textBackgroundColour == col)
-        return;
-
     m_textBackgroundColour = col;
-    if (!m_textBackgroundColour.Ok())
-        return;
 }
 
 void wxWindowDC::SetBackgroundMode( int mode )