]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listctrl.cpp
Added wxMGL switch
[wxWidgets.git] / src / msw / listctrl.cpp
index 4b38fc9819da39c8f74df59bbb7975b640d1d8b2..351c3a512f514761efab5fc08dcec30d9a8570d1 100644 (file)
@@ -216,63 +216,63 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
 #if wxUSE_EXTENDED_RTTI
 WX_DEFINE_FLAGS( wxListCtrlStyle )
 
 #if wxUSE_EXTENDED_RTTI
 WX_DEFINE_FLAGS( wxListCtrlStyle )
 
-WX_BEGIN_FLAGS( wxListCtrlStyle )
+wxBEGIN_FLAGS( wxListCtrlStyle )
     // new style border flags, we put them first to
     // use them for streaming out
     // new style border flags, we put them first to
     // use them for streaming out
-    WX_FLAGS_MEMBER(wxBORDER_SIMPLE)
-    WX_FLAGS_MEMBER(wxBORDER_SUNKEN)
-    WX_FLAGS_MEMBER(wxBORDER_DOUBLE)
-    WX_FLAGS_MEMBER(wxBORDER_RAISED)
-    WX_FLAGS_MEMBER(wxBORDER_STATIC)
-    WX_FLAGS_MEMBER(wxBORDER_NONE)
+    wxFLAGS_MEMBER(wxBORDER_SIMPLE)
+    wxFLAGS_MEMBER(wxBORDER_SUNKEN)
+    wxFLAGS_MEMBER(wxBORDER_DOUBLE)
+    wxFLAGS_MEMBER(wxBORDER_RAISED)
+    wxFLAGS_MEMBER(wxBORDER_STATIC)
+    wxFLAGS_MEMBER(wxBORDER_NONE)
     
     // old style border flags
     
     // old style border flags
-    WX_FLAGS_MEMBER(wxSIMPLE_BORDER)
-    WX_FLAGS_MEMBER(wxSUNKEN_BORDER)
-    WX_FLAGS_MEMBER(wxDOUBLE_BORDER)
-    WX_FLAGS_MEMBER(wxRAISED_BORDER)
-    WX_FLAGS_MEMBER(wxSTATIC_BORDER)
-    WX_FLAGS_MEMBER(wxNO_BORDER)
+    wxFLAGS_MEMBER(wxSIMPLE_BORDER)
+    wxFLAGS_MEMBER(wxSUNKEN_BORDER)
+    wxFLAGS_MEMBER(wxDOUBLE_BORDER)
+    wxFLAGS_MEMBER(wxRAISED_BORDER)
+    wxFLAGS_MEMBER(wxSTATIC_BORDER)
+    wxFLAGS_MEMBER(wxNO_BORDER)
 
     // standard window styles
 
     // standard window styles
-    WX_FLAGS_MEMBER(wxTAB_TRAVERSAL)
-    WX_FLAGS_MEMBER(wxCLIP_CHILDREN)
-    WX_FLAGS_MEMBER(wxTRANSPARENT_WINDOW)
-    WX_FLAGS_MEMBER(wxWANTS_CHARS)
-    WX_FLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE)
-    WX_FLAGS_MEMBER(wxALWAYS_SHOW_SB )
-    WX_FLAGS_MEMBER(wxVSCROLL)
-    WX_FLAGS_MEMBER(wxHSCROLL)
-
-    WX_FLAGS_MEMBER(wxLC_LIST)
-    WX_FLAGS_MEMBER(wxLC_REPORT)
-    WX_FLAGS_MEMBER(wxLC_ICON)
-    WX_FLAGS_MEMBER(wxLC_SMALL_ICON)
-    WX_FLAGS_MEMBER(wxLC_ALIGN_TOP)
-    WX_FLAGS_MEMBER(wxLC_ALIGN_LEFT)
-    WX_FLAGS_MEMBER(wxLC_AUTOARRANGE)
-    WX_FLAGS_MEMBER(wxLC_USER_TEXT)
-    WX_FLAGS_MEMBER(wxLC_EDIT_LABELS)
-    WX_FLAGS_MEMBER(wxLC_NO_HEADER)
-    WX_FLAGS_MEMBER(wxLC_SINGLE_SEL)
-    WX_FLAGS_MEMBER(wxLC_SORT_ASCENDING)
-    WX_FLAGS_MEMBER(wxLC_SORT_DESCENDING)
-    WX_FLAGS_MEMBER(wxLC_VIRTUAL)
-
-WX_END_FLAGS( wxListCtrlStyle )
+    wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
+    wxFLAGS_MEMBER(wxCLIP_CHILDREN)
+    wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+    wxFLAGS_MEMBER(wxWANTS_CHARS)
+    wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE)
+    wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
+    wxFLAGS_MEMBER(wxVSCROLL)
+    wxFLAGS_MEMBER(wxHSCROLL)
+
+    wxFLAGS_MEMBER(wxLC_LIST)
+    wxFLAGS_MEMBER(wxLC_REPORT)
+    wxFLAGS_MEMBER(wxLC_ICON)
+    wxFLAGS_MEMBER(wxLC_SMALL_ICON)
+    wxFLAGS_MEMBER(wxLC_ALIGN_TOP)
+    wxFLAGS_MEMBER(wxLC_ALIGN_LEFT)
+    wxFLAGS_MEMBER(wxLC_AUTOARRANGE)
+    wxFLAGS_MEMBER(wxLC_USER_TEXT)
+    wxFLAGS_MEMBER(wxLC_EDIT_LABELS)
+    wxFLAGS_MEMBER(wxLC_NO_HEADER)
+    wxFLAGS_MEMBER(wxLC_SINGLE_SEL)
+    wxFLAGS_MEMBER(wxLC_SORT_ASCENDING)
+    wxFLAGS_MEMBER(wxLC_SORT_DESCENDING)
+    wxFLAGS_MEMBER(wxLC_VIRTUAL)
+
+wxEND_FLAGS( wxListCtrlStyle )
 
 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl, wxControl,"wx/listctrl.h")
 
 
 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl, wxControl,"wx/listctrl.h")
 
-WX_BEGIN_PROPERTIES_TABLE(wxListCtrl)
-    WX_EVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent ) 
+wxBEGIN_PROPERTIES_TABLE(wxListCtrl)
+    wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent ) 
 
 
-    WX_PROPERTY_FLAGS( WindowStyle , wxListCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
-WX_END_PROPERTIES_TABLE()
+    wxPROPERTY_FLAGS( WindowStyle , wxListCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+wxEND_PROPERTIES_TABLE()
 
 
-WX_BEGIN_HANDLERS_TABLE(wxListCtrl)
-WX_END_HANDLERS_TABLE()
+wxBEGIN_HANDLERS_TABLE(wxListCtrl)
+wxEND_HANDLERS_TABLE()
 
 
-WX_CONSTRUCTOR_5( wxListCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) 
+wxCONSTRUCTOR_5( wxListCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) 
 
 /*
  TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
 
 /*
  TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
@@ -318,7 +318,7 @@ bool wxListCtrl::Create(wxWindow *parent,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
-                        const wxValidator& validator,
+                        const wxValidator& wxVALIDATOR_PARAM(validator),
                         const wxString& name)
 {
 #if wxUSE_VALIDATORS
                         const wxString& name)
 {
 #if wxUSE_VALIDATORS
@@ -390,6 +390,12 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h)
         return FALSE;
     }
 
         return FALSE;
     }
 
+    // explicitly say that we want to use Unicode because otherwise we get ANSI
+    // versions of _some_ messages (notably LVN_GETDISPINFOA) in MSLU build
+#if wxUSE_UNICODE
+    ::SendMessage(GetHwnd(), LVM_SETUNICODEFORMAT, TRUE, 0);
+#endif
+
     // for comctl32.dll v 4.70+ we want to have this attribute because it's
     // prettier (and also because wxGTK does it like this)
     if ( (wstyle & LVS_REPORT) && wxTheApp->GetComCtl32Version() >= 470 )
     // for comctl32.dll v 4.70+ we want to have this attribute because it's
     // prettier (and also because wxGTK does it like this)
     if ( (wstyle & LVS_REPORT) && wxTheApp->GetComCtl32Version() >= 470 )
@@ -1026,6 +1032,25 @@ bool wxListCtrl::SetItemData(long item, long data)
     return SetItem(info);
 }
 
     return SetItem(info);
 }
 
+wxRect wxListCtrl::GetViewRect() const
+{
+    wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST),
+                    _T("wxListCtrl::GetViewRect() only works in icon mode") );
+
+    RECT rc;
+    if ( !ListView_GetViewRect(GetHwnd(), &rc) )
+    {
+        wxLogDebug(_T("ListView_GetViewRect() failed."));
+
+        wxZeroMemory(rc);
+    }
+
+    wxRect rect;
+    wxCopyRECTToRect(rc, rect);
+
+    return rect;
+}
+
 // Gets the item rectangle
 bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
 {
 // Gets the item rectangle
 bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
 {
@@ -1078,9 +1103,13 @@ int wxListCtrl::GetItemCount() const
     return m_count;
 }
 
     return m_count;
 }
 
-// Retrieves the spacing between icons in pixels.
-// If small is TRUE, gets the spacing for the small icon
-// view, otherwise the large icon view.
+wxSize wxListCtrl::GetItemSpacing() const
+{
+    const int spacing = ListView_GetItemSpacing(GetHwnd(), (BOOL)HasFlag(wxLC_SMALL_ICON));
+
+    return wxSize(LOWORD(spacing), HIWORD(spacing));
+}
+
 int wxListCtrl::GetItemSpacing(bool isSmall) const
 {
     return ListView_GetItemSpacing(GetHwnd(), (BOOL) isSmall);
 int wxListCtrl::GetItemSpacing(bool isSmall) const
 {
     return ListView_GetItemSpacing(GetHwnd(), (BOOL) isSmall);
@@ -1506,16 +1535,17 @@ long wxListCtrl::InsertItem(wxListItem& info)
         if (info.m_mask & wxLIST_MASK_DATA)
             data->lParam = info.m_data;
 
         if (info.m_mask & wxLIST_MASK_DATA)
             data->lParam = info.m_data;
 
-    // check whether it has any custom attributes
-    if ( info.HasAttributes() )
-    {
+        // check whether it has any custom attributes
+        if ( info.HasAttributes() )
+        {
             // take copy of attributes
             data->attr = new wxListItemAttr(*info.GetAttributes());
             // take copy of attributes
             data->attr = new wxListItemAttr(*info.GetAttributes());
-    }
+        }
     };
 
     long rv = ListView_InsertItem(GetHwnd(), & item);
     };
 
     long rv = ListView_InsertItem(GetHwnd(), & item);
-    m_count += 1;
+
+    m_count++;
     wxASSERT_MSG( m_count == ListView_GetItemCount(GetHwnd()),
                   wxT("m_count should match ListView_GetItemCount"));
 
     wxASSERT_MSG( m_count == ListView_GetItemCount(GetHwnd()),
                   wxT("m_count should match ListView_GetItemCount"));