]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/wrapdfb.cpp
Add missing WXK constants for the control keys
[wxWidgets.git] / src / dfb / wrapdfb.cpp
index afd6ee064b0e8a57d1fa7bfbe790dfbd5cbeebcf..6159b7df16a968c1981a00fda9e73fdd95c864cb 100644 (file)
     #pragma hdrstop
 #endif
 
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/log.h"
+#endif
+
 #include "wx/dfb/wrapdfb.h"
 
 //-----------------------------------------------------------------------------
@@ -31,7 +36,7 @@ bool wxDfbCheckReturn(DFBResult code)
         // these are programming errors, assert:
         #define DFB_ASSERT(code)                                        \
             case code:                                                  \
-                wxFAIL_MSG( _T("DirectFB error: ") _T(#code) );         \
+                wxFAIL_MSG( "DirectFB error: " wxT(#code) );         \
                 return false                                            \
 
         DFB_ASSERT(DFB_DEAD);
@@ -56,7 +61,7 @@ bool wxDfbCheckReturn(DFBResult code)
 
         default:
             // FIXME: should handle the errors individually
-            wxLogError(_("DirectFB error %d occured."), (int)code);
+            wxLogError(_("DirectFB error %d occurred."), (int)code);
             return false;
     }
 }
@@ -98,14 +103,29 @@ void wxIDirectFB::CleanUp()
 
 wxIDirectFBSurfacePtr wxIDirectFB::GetPrimarySurface()
 {
-    wxIDirectFBDisplayLayerPtr layer(GetDisplayLayer());
-    return layer ? layer->GetSurface() : NULL;
+    DFBSurfaceDescription desc;
+    desc.flags = DSDESC_CAPS;
+    // NB: see dcscreen.cpp for why we request double-buffered surface
+    //
+    //     This assumes the cooperative level is DFSCL_NORMAL (that's the
+    //     default and wx doesn't modify it anywhere); if we ever support
+    //     other cooperative levels, DSCAPS_DOUBLE should *not* be used with
+    //     them.
+    desc.caps = DFBSurfaceCapabilities(DSCAPS_PRIMARY | DSCAPS_DOUBLE);
+    return CreateSurface(&desc);
 }
 
 //-----------------------------------------------------------------------------
 // wxIDirectFBSurface
 //-----------------------------------------------------------------------------
 
+DFBSurfacePixelFormat wxIDirectFBSurface::GetPixelFormat()
+{
+    DFBSurfacePixelFormat format = DSPF_UNKNOWN;
+    GetPixelFormat(&format);
+    return format;
+}
+
 int wxIDirectFBSurface::GetDepth()
 {
     DFBSurfacePixelFormat format = DSPF_UNKNOWN;
@@ -126,7 +146,7 @@ wxIDirectFBSurface::CreateCompatible(const wxSize& sz, int flags)
             return NULL;
     }
 
-    wxCHECK_MSG( size.x > 0 && size.y > 0, NULL, _T("invalid size") );
+    wxCHECK_MSG( size.x > 0 && size.y > 0, NULL, "invalid size" );
 
     DFBSurfaceDescription desc;
     desc.flags = (DFBSurfaceDescriptionFlags)(
@@ -192,3 +212,26 @@ bool wxIDirectFBSurface::FlipToFront(const DFBRegion *region)
     // drawings:
     return Flip(region, DSFLIP_BLIT);
 }
+
+//-----------------------------------------------------------------------------
+// wxIDirectFBDisplayLayer
+//-----------------------------------------------------------------------------
+
+wxVideoMode wxIDirectFBDisplayLayer::GetVideoMode()
+{
+    DFBDisplayLayerConfig cfg;
+    if ( !GetConfiguration(&cfg) )
+        return wxVideoMode(); // invalid
+
+    if ( !((cfg.flags & DLCONF_WIDTH) &&
+           (cfg.flags & DLCONF_HEIGHT) &&
+           (cfg.flags & DLCONF_PIXELFORMAT)) )
+        return wxVideoMode(); // invalid
+
+    return wxVideoMode
+           (
+             cfg.width,
+             cfg.height,
+             DFB_BITS_PER_PIXEL(cfg.pixelformat)
+           );
+}