]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/list.h
Implemented PocketPC menubar/toolbar as wxToolMenuBar derived
[wxWidgets.git] / include / wx / list.h
index 97a965b24662d4cbf8f50bce0aefbe80a6c96e56..cb7023d3b7678dedb56243a12c03f3f7c91b3bbb 100644 (file)
@@ -98,7 +98,26 @@ enum wxKeyType
 #define WX_DECLARE_LIST_WITH_DECL(elT, liT, decl) \
     WX_DECLARE_LIST_XO(elT*, liT, decl)
 
-#define WX_DECLARE_LIST_XO(elT, liT, decl)                                    \
+#if !defined( __VISUALC__ )
+
+template<class T>
+class WXDLLIMPEXP_BASE wxList_SortFunction
+{
+public:
+    wxList_SortFunction(wxSortCompareFunction f) : m_f(f) { }
+    bool operator()(const T& i1, const T& i2)
+      { return m_f((T*)&i1, (T*)&i2) < 0; }
+private:
+    wxSortCompareFunction m_f;
+};
+
+#define WX_LIST_SORTFUNCTION( elT, f ) wxList_SortFunction<elT>(f)
+#define VC6_WORKAROUND(elT, liT, decl)
+
+#else // if defined( __VISUALC__ )
+
+#define WX_LIST_SORTFUNCTION( elT, f ) std::greater<elT>( f )
+#define VC6_WORKAROUND(elT, liT, decl)                                        \
     decl liT;                                                                 \
                                                                               \
     /* Workaround for broken VC6 STL incorrectly requires a std::greater<> */ \
@@ -117,8 +136,12 @@ enum wxKeyType
                         ( m_CompFunc( X, Y ) < 0 ) :                          \
                         ( X > Y );                                            \
                 }                                                             \
-    };                                                                        \
-                                                                              \
+    };
+
+#endif // defined( __VISUALC__ )
+
+#define WX_DECLARE_LIST_XO(elT, liT, decl)                                    \
+    VC6_WORKAROUND(elT, liT, decl)                                            \
     decl liT : public std::list<elT>                                          \
     {                                                                         \
     private:                                                                  \
@@ -269,11 +292,9 @@ enum wxKeyType
                 std::for_each( begin(), end(), DeleteFunction );              \
             clear();                                                          \
         }                                                                     \
-                                                                              \
         /* Workaround for broken VC6 std::list::sort() see above */           \
         void Sort( wxSortCompareFunction compfunc )                           \
-            { sort( std::greater<elT>( compfunc ) ); }                        \
-                                                                              \
+            { sort( WX_LIST_SORTFUNCTION( elT, compfunc ) ); }                \
         ~liT() { Clear(); }                                                   \
     }