]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/defs.h
adding new toolkits for osx
[wxWidgets.git] / include / wx / defs.h
index c9754282f775a560d4db1543a3ab7686607a74b9..d9aad8ce61b3d6732d66e6fc0d4c8bf5a49bff65 100644 (file)
@@ -36,7 +36,9 @@
          !defined(__WXPALMOS__)&& \
          !defined(__WXGTK__)   && \
          !defined(__WXPM__)    && \
-         !defined(__WXMAC__)   && \
+         !defined(__WXOSX_CARBON__)   && \
+         !defined(__WXOSX_COCOA__)   && \
+         !defined(__WXOSX_IPHONE__)   && \
          !defined(__WXCOCOA__) && \
          !defined(__X__)       && \
          !defined(__WXMGL__)   && \
@@ -611,15 +613,33 @@ typedef short int WXTYPE;
 #include <stddef.h>
 #endif
 
-/*  delete pointer if it is not NULL and NULL it afterwards */
-/*  (checking that it's !NULL before passing it to delete is just a */
-/*   a question of style, because delete will do it itself anyhow, but it might */
-/*   be considered as an error by some overzealous debugging implementations of */
-/*   the library, so we do it ourselves) */
-#define wxDELETE(p)      if ( (p) != NULL ) { delete p; p = NULL; }
+#ifdef __cplusplus
+    // delete pointer if it is not NULL and NULL it afterwards
+    template <typename T>
+    inline void wxDELETE(T*& ptr)
+    {
+        typedef char TypeIsCompleteCheck[sizeof(T)];
+
+        if ( ptr != NULL )
+        {
+            delete ptr;
+            ptr = NULL;
+        }
+    }
 
-/*  delete an array and NULL it (see comments above) */
-#define wxDELETEA(p)     if ( (p) ) { delete [] (p); p = NULL; }
+    // delete an array and NULL it (see comments above)
+    template <typename T>
+    inline void wxDELETEA(T*& ptr)
+    {
+        typedef char TypeIsCompleteCheck[sizeof(T)];
+
+        if ( ptr != NULL )
+        {
+            delete [] ptr;
+            ptr = NULL;
+        }
+    }
+#endif /*__cplusplus*/
 
 /*  size of statically declared array */
 #define WXSIZEOF(array)   (sizeof(array)/sizeof(array[0]))
@@ -1101,20 +1121,26 @@ typedef wxUint32 wxDword;
 #endif
 
 
-/* Make sure ssize_t is defined (a signed type the same size as size_t) */
-/* HAVE_SSIZE_T should be defined for compiliers that already have it */
+/* Make sure ssize_t is defined (a signed type the same size as size_t). */
+/* (HAVE_SSIZE_T is not already defined by configure) */
+#ifndef HAVE_SSIZE_T
 #ifdef __MINGW32__
-    #if defined(_SSIZE_T_) && !defined(HAVE_SSIZE_T)
+    #if defined(_SSIZE_T_) || defined(_SSIZE_T_DEFINED)
         #define HAVE_SSIZE_T
     #endif
-#endif
-#if defined(__PALMOS__) && !defined(HAVE_SSIZE_T)
+#elif defined(__PALMOS__)
     #define HAVE_SSIZE_T
-#endif
-#if wxCHECK_WATCOM_VERSION(1,4)
+#elif wxCHECK_WATCOM_VERSION(1,4)
     #define HAVE_SSIZE_T
 #endif
-#ifndef HAVE_SSIZE_T
+#endif /* !HAVE_SSIZE_T */
+
+/* If we really don't have ssize_t, provide our own version. */
+#ifdef HAVE_SSIZE_T
+    #ifdef __UNIX__
+        #include <sys/types.h>
+    #endif
+#else // !HAVE_SSIZE_T
     #if SIZEOF_SIZE_T == 4
         typedef wxInt32 ssize_t;
     #elif SIZEOF_SIZE_T == 8
@@ -1124,6 +1150,17 @@ typedef wxUint32 wxDword;
     #endif
 #endif
 
+// we can't rely on Windows _W64 being defined as windows.h may not be included
+// so define our own equivalent: this should be used with types like WXLPARAM
+// or WXWPARAM which are 64 bit under Win64 to avoid warnings each time we cast
+// it to a pointer or a handle (which results in hundreds of warnings as Win32
+// API often passes pointers in them)
+#if wxCHECK_VISUALC_VERSION(7)
+    #define wxW64 __w64
+#else
+    #define wxW64
+#endif
+
 /*
    Define signed and unsigned integral types big enough to contain all of long,
    size_t and void *.
@@ -1132,13 +1169,11 @@ typedef wxUint32 wxDword;
     /*
        Win64 case: size_t is the only integral type big enough for "void *".
 
-       Notice that wxUIntPtr should be also defined as size_t when building
-       under Win32 with MSVC with /Wp64 option as otherwise any conversion
-       between ints and pointers results in a warning 4311 or 4312, even if it
-       is safe under Win32. Using size_t (declared with __w64) allows to avoid
-       them.
+       Notice that we must use __w64 to avoid warnings about casting pointers
+       to wxIntPtr (which we do often as this is what it is defined for) in 32
+       bit build with MSVC.
      */
-    #define wxIntPtr ssize_t
+    typedef wxW64 ssize_t wxIntPtr;
     typedef size_t wxUIntPtr;
 #elif SIZEOF_LONG >= SIZEOF_VOID_P
     /*
@@ -1260,6 +1295,24 @@ typedef double wxDouble;
  */
 #define wxNullPtr ((void *)NULL)
 
+
+/* Define wxChar16 and wxChar32                                              */
+
+#if wxUSE_WCHAR_T && (!defined(SIZEOF_WCHAR_T) || (SIZEOF_WCHAR_T == 2))
+    #define wxWCHAR_T_IS_WXCHAR16
+    typedef wchar_t wxChar16; 
+#else
+    typedef wxUint16 wxChar16;
+#endif
+
+#if wxUSE_WCHAR_T && defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4)
+    #define wxWCHAR_T_IS_WXCHAR32
+    typedef wchar_t wxChar32;
+#else
+    typedef wxUint32 wxChar32;
+#endif
+
+
 /*  ---------------------------------------------------------------------------- */
 /*  byte ordering related definition and macros */
 /*  ---------------------------------------------------------------------------- */
@@ -1392,6 +1445,8 @@ typedef double wxDouble;
     #if wxHAS_INT64
         #define wxUINT64_SWAP_ON_BE(val)  wxUINT64_SWAP_ALWAYS(val)
         #define wxUINT64_SWAP_ON_LE(val)  (val)
+        #define wxINT64_SWAP_ON_BE(val)  wxINT64_SWAP_ALWAYS(val)
+        #define wxINT64_SWAP_ON_LE(val)  (val)
     #endif
 #else
     #define wxUINT16_SWAP_ON_LE(val)  wxUINT16_SWAP_ALWAYS(val)
@@ -1405,6 +1460,8 @@ typedef double wxDouble;
     #if wxHAS_INT64
         #define wxUINT64_SWAP_ON_LE(val)  wxUINT64_SWAP_ALWAYS(val)
         #define wxUINT64_SWAP_ON_BE(val)  (val)
+        #define wxINT64_SWAP_ON_LE(val)  wxINT64_SWAP_ALWAYS(val)
+        #define wxINT64_SWAP_ON_BE(val)  (val)
     #endif
 #endif
 
@@ -1991,6 +2048,24 @@ enum
     wxID_ZOOM_OUT,
     wxID_UNDELETE,
     wxID_REVERT_TO_SAVED,
+    wxID_CDROM,
+    wxID_CONVERT,
+    wxID_EXECUTE,
+    wxID_FLOPPY,
+    wxID_HARDDISK,
+    wxID_BOTTOM,
+    wxID_FIRST,
+    wxID_LAST,
+    wxID_TOP,
+    wxID_INFO,
+    wxID_JUMP_TO,
+    wxID_NETWORK,
+    wxID_SELECT_COLOR,
+    wxID_SELECT_FONT,
+    wxID_SORT_ASCENDING,
+    wxID_SORT_DESCENDING,
+    wxID_SPELL_CHECK,
+    wxID_STRIKETHROUGH,
 
     /*  System menu IDs (used by wxUniv): */
     wxID_SYSTEM_MENU = 5200,
@@ -2620,15 +2695,18 @@ typedef void*       WXEVENTREF;
 typedef void*       WXEVENTHANDLERREF;
 typedef void*       WXEVENTHANDLERCALLREF;
 typedef void*       WXAPPLEEVENTREF;
-typedef void*       WXHMENU;
 
 typedef unsigned int    WXUINT;
 typedef unsigned long   WXDWORD;
 typedef unsigned short  WXWORD;
 
 typedef WX_OPAQUE_TYPE(PicHandle ) * WXHMETAFILE ;
+#if wxOSX_USE_CARBON
 typedef WX_OPAQUE_TYPE(ControlRef ) * WXWidget ;
 typedef WX_OPAQUE_TYPE(WindowRef) * WXWindow ;
+typedef struct __AGLPixelFormatRec   *WXGLPixelFormat;
+typedef struct __AGLContextRec       *WXGLContext;
+#endif
 
 typedef void*       WXDisplay;
 
@@ -2664,9 +2742,13 @@ typedef struct __HIShape * HIMutableShapeRef;
 
 DECLARE_WXMAC_OPAQUE_REF( PasteboardRef )
 DECLARE_WXMAC_OPAQUE_REF( IconRef )
+DECLARE_WXMAC_OPAQUE_REF( MenuRef )
 
 typedef IconRef WXHICON ;
 typedef HIShapeRef WXHRGN;
+#if wxOSX_USE_CARBON
+typedef MenuRef WXHMENU;
+#endif
 
 #endif
 
@@ -2765,15 +2847,38 @@ DECLARE_WXCOCOA_OBJC_CLASS(NSTextStorage);
 DECLARE_WXCOCOA_OBJC_CLASS(NSThread);
 DECLARE_WXCOCOA_OBJC_CLASS(NSWindow);
 DECLARE_WXCOCOA_OBJC_CLASS(NSView);
-#ifdef __WXMAC__
-// things added for __WXMAC__
-DECLARE_WXCOCOA_OBJC_CLASS(NSString);
-#else
-// things only for __WXCOCOA__
+DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLContext);
+DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLPixelFormat);
+#ifndef __WXMAC__
 typedef WX_NSView WXWidget; /*  wxWidgets BASE definition */
 #endif
 #endif /*  __WXCOCOA__  || ( __WXMAC__ &__DARWIN__)*/
 
+#ifdef __WXMAC__
+
+DECLARE_WXCOCOA_OBJC_CLASS(NSString);
+
+#if wxOSX_USE_COCOA
+
+typedef WX_NSWindow WXWindow;
+typedef WX_NSView WXWidget;
+typedef WX_NSMenu WXHMENU;
+typedef WX_NSOpenGLPixelFormat WXGLPixelFormat;
+typedef WX_NSOpenGLContext WXGLContext;
+
+#elif wxOSX_USE_IPHONE
+
+DECLARE_WXCOCOA_OBJC_CLASS(UIWindow);
+DECLARE_WXCOCOA_OBJC_CLASS(UIView);
+DECLARE_WXCOCOA_OBJC_CLASS(UIFont);
+
+typedef WX_UIWindow WXWindow;
+typedef WX_UIView WXWidget;
+
+#endif
+
+#endif // __WXMAC__
+
 #if defined(__WXPALMOS__)
 
 typedef void *          WXHWND;
@@ -2817,17 +2922,6 @@ typedef void *          WXRECTANGLEPTR;
 #    define WXFAR
 #endif
 
-// we can't rely on Windows _W64 being defined as windows.h may not be included
-// so define our own equivalent: this should be used with types like WXLPARAM
-// or WXWPARAM which are 64 bit under Win64 to avoid warnings each time we cast
-// it to a pointer or a handle (which results in hundreds of warnings as Win32
-// API often passes pointers in them)
-#if wxCHECK_VISUALC_VERSION(7)
-    #define wxW64 __w64
-#else
-    #define wxW64
-#endif
-
 /*  Stand-ins for Windows types to avoid #including all of windows.h */
 typedef void *          WXHWND;
 typedef void *          WXHANDLE;
@@ -3123,6 +3217,11 @@ typedef const void* WXWidget;
         classname(const classname&);            \
         classname& operator=(const classname&);
 
+#define DECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg)  \
+    private:                                            \
+        classname(const classname<arg>&);               \
+        classname& operator=(const classname<arg>&);
+
 #define DECLARE_NO_ASSIGN_CLASS(classname)      \
     private:                                    \
         classname& operator=(const classname&);