]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/checklst.cpp
typofix
[wxWidgets.git] / src / msw / checklst.cpp
index 2fb4e4e5087e0a8818880a02f73d08d93325e916..fd480f4f705c848a28c36ec7f6970b6131b6ce29 100644 (file)
@@ -47,6 +47,7 @@
 
 #include "wx/renderer.h"
 #include "wx/msw/private.h"
+#include "wx/msw/dc.h"
 
 // ----------------------------------------------------------------------------
 // private functions
@@ -124,7 +125,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
 
 class wxCheckListBoxItem : public wxOwnerDrawn
 {
-friend class WXDLLEXPORT wxCheckListBox;
+friend class WXDLLIMPEXP_FWD_CORE wxCheckListBox;
 public:
     // ctor
     wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex);
@@ -174,8 +175,9 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
     if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) )
         return false;
 
+    wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
     // now draw the check mark part
-    HDC hdc = GetHdcOf(dc);
+    HDC hdc = GetHdcOf(*impl);
 
     int nBmpWidth  = ::GetSystemMetrics(SM_CXMENUCHECK),
         nBmpHeight = ::GetSystemMetrics(SM_CYMENUCHECK);
@@ -251,6 +253,7 @@ void wxCheckListBoxItem::SendEvent()
     wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId());
     event.SetInt(m_nIndex);
     event.SetEventObject(m_pParent);
+    event.SetString(m_pParent->GetString(m_nIndex));
     m_pParent->ProcessCommand(event);
 }
 
@@ -482,9 +485,19 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
 
         if ( nItem != wxNOT_FOUND )
         {
-            wxCheckListBoxItem *item = GetItem(nItem);
-            item->Toggle();
-            item->SendEvent();
+            // people expect to get "kill focus" event for the currently
+            // focused control before getting events from the other controls
+            // and, equally importantly, they may prevent the focus change from
+            // taking place at all (e.g. because the old control contents is
+            // invalid and needs to be corrected) in which case we shouldn't
+            // generate this event at all
+            SetFocus();
+            if ( FindFocus() == this )
+            {
+                wxCheckListBoxItem *item = GetItem(nItem);
+                item->Toggle();
+                item->SendEvent();
+            }
         }
         //else: it's not an error, just click outside of client zone
     }