]> git.saurik.com Git - wxWidgets.git/commitdiff
make it possible to create wxWindowDC for a hidden window
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 10 Sep 2006 15:51:03 +0000 (15:51 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 10 Sep 2006 15:51:03 +0000 (15:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41131 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dfb/private.h
src/dfb/dcclient.cpp
src/dfb/utils.cpp

index 23c6d830acaaa855af89431604aeed8341240648..8e005dace13c92ef4c3409ccdd672f9b4c46015e 100644 (file)
@@ -41,6 +41,14 @@ enum wxDfbCloneSurfaceMode
     wxDfbCloneSurface_CopyPixels
 };
 
     wxDfbCloneSurface_CopyPixels
 };
 
+/**
+    Creates surface that is compatible with given @a surface (i.e. has same
+    capabilities, pixel format etc.) and has given @a size.
+ */
+wxIDirectFBSurfacePtr wxDfbCreateCompatibleSurface(
+                                    const wxIDirectFBSurfacePtr& surface,
+                                    const wxSize& size);
+
 /**
     Creates a new surface by cloning existing one. Depending on @a mode,
     either makes exact copy (wxDfbCloneSurface_CopyPixels) or only creates a
 /**
     Creates a new surface by cloning existing one. Depending on @a mode,
     either makes exact copy (wxDfbCloneSurface_CopyPixels) or only creates a
index 3ded9ca71923dafac781a057491b42b567e7a52d..17940083ea629be46881aa8fcff909caf5971e3f 100644 (file)
@@ -50,28 +50,24 @@ void wxWindowDC::InitForWin(wxWindow *win, const wxRect *rect)
 {
     wxCHECK_RET( win, _T("invalid window") );
 
 {
     wxCHECK_RET( win, _T("invalid window") );
 
-    // FIXME: this should be made to work: we need to detect that the window
-    //        is not visible and in that case, a) ignore any drawing actions
-    //        and b) provide dummy surface that can still be used to get
-    //        information (e.g. text extents):
-    for ( wxWindow *w = win; w; w = w->GetParent() )
-    {
-        // painting on hidden TLW when non-TLW windows are shown is OK,
-        // DirectFB manages that:
-        if ( w->IsTopLevel() )
-            break;
-
-        wxASSERT_MSG( w->IsShown(),
-                      _T("painting on hidden window not implemented yet") );
-    }
-
     // check if the rectangle covers full window and so is not needed:
     if ( rect && *rect == wxRect(win->GetSize()) )
         rect = NULL;
 
     // obtain the surface used for painting:
     wxIDirectFBSurfacePtr surface;
     // check if the rectangle covers full window and so is not needed:
     if ( rect && *rect == wxRect(win->GetSize()) )
         rect = NULL;
 
     // obtain the surface used for painting:
     wxIDirectFBSurfacePtr surface;
-    if ( !rect )
+
+    if ( !win->IsVisible() )
+    {
+        // we're painting on invisible window: the changes won't have any
+        // effect, as the window will be repainted anyhow when it is shown, but
+        // we still need a valid DC so that e.g. text extents can be measured,
+        // so let's create a dummy surface that has the same format as the real
+        // one would have and let the code paint on it:
+        wxSize size(rect ? rect->GetSize() : win->GetSize());
+        surface = wxDfbCreateCompatibleSurface(win->GetDfbSurface(), size);
+    }
+    else if ( !rect )
     {
         wxCHECK_RET( win->GetSize().x > 0 && win->GetSize().y > 0,
                      _T("window has invalid size") );
     {
         wxCHECK_RET( win->GetSize().x > 0 && win->GetSize().y > 0,
                      _T("window has invalid size") );
index b3ab8d5b257a39edb2f85d65647ffd56d04b9e31..2f1e7da32ea35d3fc26b9be2d605f70148b6b6d8 100644 (file)
@@ -87,8 +87,9 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
 // surface manipulation helpers
 //-----------------------------------------------------------------------------
 
 // surface manipulation helpers
 //-----------------------------------------------------------------------------
 
-wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
-                                        wxDfbCloneSurfaceMode mode)
+wxIDirectFBSurfacePtr wxDfbCreateCompatibleSurface(
+                                    const wxIDirectFBSurfacePtr& s,
+                                    const wxSize& size)
 {
     if ( !s )
         return NULL;
 {
     if ( !s )
         return NULL;
@@ -97,8 +98,9 @@ wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
     desc.flags = (DFBSurfaceDescriptionFlags)(
             DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT);
     s->GetCapabilities(&desc.caps);
     desc.flags = (DFBSurfaceDescriptionFlags)(
             DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT);
     s->GetCapabilities(&desc.caps);
-    s->GetSize(&desc.width, &desc.height);
     s->GetPixelFormat(&desc.pixelformat);
     s->GetPixelFormat(&desc.pixelformat);
+    desc.width = size.x;
+    desc.height = size.y;
 
     wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
     if ( !snew )
 
     wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
     if ( !snew )
@@ -114,6 +116,23 @@ wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
         }
     }
 
         }
     }
 
+    return snew;
+}
+
+wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
+                                        wxDfbCloneSurfaceMode mode)
+{
+    if ( !s )
+        return NULL;
+
+    wxSize size;
+    if ( !s->GetSize(&size.x, &size.y) )
+        return NULL;
+
+    wxIDirectFBSurfacePtr snew(wxDfbCreateCompatibleSurface(s, size));
+    if ( !snew )
+        return NULL;
+
     if ( mode == wxDfbCloneSurface_CopyPixels )
     {
         if ( !snew->SetBlittingFlags(DSBLIT_NOFX) )
     if ( mode == wxDfbCloneSurface_CopyPixels )
     {
         if ( !snew->SetBlittingFlags(DSBLIT_NOFX) )