]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed various NULL reference issues. Also cleaned up wxPGComboBox code overall a...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sat, 15 Nov 2008 10:34:36 +0000 (10:34 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sat, 15 Nov 2008 10:34:36 +0000 (10:34 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56782 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
include/wx/propgrid/propgriddefs.h
include/wx/propgrid/propgridiface.h
src/propgrid/editors.cpp

index 1dd48d53d40494317459fb823c02780e71d23881..a35360ccce93addf13dbb730a347d754fe4e7949 100644 (file)
@@ -27,6 +27,7 @@
 extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr[];
 #endif
 
+class wxPGComboBox;
 
 // -----------------------------------------------------------------------
 // Global variables
@@ -1219,8 +1220,11 @@ public:
     void IncFrozen() { m_frozen++; }
     void DecFrozen() { m_frozen--; }
 
-    void OnComboItemPaint( wxPGCustomComboControl* pCb,int item,wxDC& dc,
-                           wxRect& rect,int flags );
+    void OnComboItemPaint( const wxPGComboBox* pCb,
+                           int item,
+                           wxDC* pDc,
+                           wxRect& rect,
+                           int flags );
 
     /** Standardized double-to-string conversion.
     */
index d72a78709541992c7eab3bb1092d8dfec12b0c7e..02e4fc0f2d26ffd1c4caec9c35f316e39b017cf8 100644 (file)
@@ -266,7 +266,6 @@ class wxPropertyGrid;
 class wxPropertyGridEvent;
 class wxPropertyGridManager;
 class wxPGOwnerDrawnComboBox;
-class wxPGCustomComboControl;
 class wxPGEditorDialogAdapter;
 class wxPGValidationInfo;
 
index e12f9248f3b8811f52cd9f291cc1ec8c4c2f8bca..a2139e45e945eb05e04f432309e9d441d2865844 100644 (file)
@@ -363,7 +363,10 @@ public:
     */
     const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const
     {
-        wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((const wxPGAttributeStorage*)NULL));
+        // If 'id' refers to invalid property, then we will return dummy
+        // attributes (ie. root property's attributes, which contents should
+        // should always be empty and of no consequence).
+        wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState->DoGetRoot()->GetAttributes());
         return p->GetAttributes();
     }
 
index fb60bdaa5f65c85cfc0feebf78f868ff346554dc..0f63021c567b7b721db9cb458fd15b16c1ec66b1 100644 (file)
@@ -528,31 +528,37 @@ public:
                                             name ) )
             return false;
 
-        m_dclickProcessor = new wxPGDoubleClickProcessor(this, GetGrid()->GetSelection() );
+        m_dclickProcessor = new
+            wxPGDoubleClickProcessor( this, GetGrid()->GetSelection() );
 
         PushEventHandler(m_dclickProcessor);
 
         return true;
     }
 
-    virtual void OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const
+    virtual void OnDrawItem( wxDC& dc,
+                             const wxRect& rect,
+                             int item,
+                             int flags ) const
     {
         wxPropertyGrid* pg = GetGrid();
-        pg->OnComboItemPaint((wxPGCustomComboControl*)this,item,dc,(wxRect&)rect,flags);
+        pg->OnComboItemPaint( this, item, &dc, (wxRect&)rect, flags );
     }
+
     virtual wxCoord OnMeasureItem( size_t item ) const
     {
         wxPropertyGrid* pg = GetGrid();
         wxRect rect;
         rect.x = -1;
         rect.width = 0;
-        pg->OnComboItemPaint((wxPGCustomComboControl*)this,item,*((wxDC*)NULL),rect,0);
+        pg->OnComboItemPaint( this, item, NULL, rect, 0 );
         return rect.height;
     }
 
     wxPropertyGrid* GetGrid() const
     {
-        wxPropertyGrid* pg = wxDynamicCast(GetParent()->GetParent(),wxPropertyGrid);
+        wxPropertyGrid* pg = wxDynamicCast(GetParent()->GetParent(),
+                                           wxPropertyGrid);
         wxASSERT(pg);
         return pg;
     }
@@ -563,15 +569,17 @@ public:
         wxRect rect;
         rect.x = -1;
         rect.width = -1;
-        pg->OnComboItemPaint((wxPGCustomComboControl*)this,item,*((wxDC*)NULL),rect,0);
+        pg->OnComboItemPaint( this, item, NULL, rect, 0 );
         return rect.width;
     }
 
-    virtual void PositionTextCtrl( int WXUNUSED(textCtrlXAdjust), int WXUNUSED(textCtrlYAdjust) )
+    virtual void PositionTextCtrl( int WXUNUSED(textCtrlXAdjust),
+                                   int WXUNUSED(textCtrlYAdjust) )
     {
         wxPropertyGrid* pg = GetGrid();
         wxOwnerDrawnComboBox::PositionTextCtrl(
-            wxPG_TEXTCTRLXADJUST - (wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1,
+            wxPG_TEXTCTRLXADJUST -
+            (wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1,
             pg->GetSpacingY() + 2
         );
     }
@@ -582,14 +590,12 @@ private:
 };
 
 
-void wxPropertyGrid::OnComboItemPaint( wxPGCustomComboControl* pCc,
+void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb,
                                        int item,
-                                       wxDC& dc,
+                                       wxDC* pDc,
                                        wxRect& rect,
                                        int flags )
 {
-    wxPGComboBox* pCb = (wxPGComboBox*)pCc;
-
     // Sanity check
     wxASSERT( IsKindOf(CLASSINFO(wxPropertyGrid)) );
 
@@ -669,13 +675,14 @@ void wxPropertyGrid::OnComboItemPaint( wxPGCustomComboControl* pCc,
     if ( (flags & wxODCB_PAINTING_CONTROL) )
         paintdata.m_choiceItem = -1;
 
-    if ( &dc )
-        dc.SetBrush(*wxWHITE_BRUSH);
+    if ( pDc )
+        pDc->SetBrush(*wxWHITE_BRUSH);
 
     if ( rect.x >= 0 )
     {
         //
         // DrawItem call
+        wxDC& dc = *pDc;
 
         wxPoint pt(rect.x + wxPG_CONTROL_MARGIN - wxPG_CHOICEXADJUST - 1,
                    rect.y + 1);
@@ -760,6 +767,7 @@ void wxPropertyGrid::OnComboItemPaint( wxPGCustomComboControl* pCc,
     {
         //
         // MeasureItem call
+        wxDC& dc = *pDc;
 
         p->OnCustomPaint( dc, rect, paintdata );
         rect.height = paintdata.m_drawnHeight + 2;