]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed wxMotif's wxRegion/wxRegionIterator to optionally use wxRects.
authorJulian Smart <julian@anthemion.co.uk>
Wed, 27 Oct 1999 08:59:23 +0000 (08:59 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 27 Oct 1999 08:59:23 +0000 (08:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

distrib/msw/generic.rsp
docs/html/index.htm
include/wx/motif/region.h
include/wx/motif/window.h
src/generic/choicdgg.cpp
src/motif/dcclient.cpp
src/motif/region.cpp
src/motif/window.cpp

index be6ab947ac98771ade94dc02992f459aaa784999..560c128109ade8422b047250223dcfe14294195d 100644 (file)
@@ -125,8 +125,6 @@ include/wx/html/msw/*.ico
 include/wx/html/msw/*.rc
 lib/dummy
 
-bin/*.*
-
 tools/gettext/*.*
 
 bitmaps/xpm/16x16/*.*
index f00dc99c3864a31c40c4bf3ccbc7ca67d9c433f2..b5c0f39264988a128c70c990ed87c9764ec9a60f 100644 (file)
@@ -206,6 +206,7 @@ For printing-related dialogs, see the printing sample.
 using wxFrame.
 <li><a href="../../samples/docvwmdi">docvwmdi</a>: : demonstrates use of the document view classes,
 using wxMDIParentFrame, wxMDIChildFrame.
+<li><a href="../../samples/drawing">drawing</a>: tests device context drawing.
 <li><a href="../../samples/dynamic">dynamic</a>: shows how to connect events to member functions
 dynamically.
 <li><a href="../../samples/forty">forty</a>: a great little card game by Chris Breeze. A
index 969a44f6545e7dd57838e0f49cf41633eb56fbe4..e5bcccbd4df5bdd417d59668b99062633807a011 100644 (file)
 #include "wx/gdiobj.h"
 #include "wx/gdicmn.h"
 
-class WXDLLEXPORT wxRect;
-class WXDLLEXPORT wxPoint;
+// ----------------------------------------------------------------------------
+// A list of rectangles type used by wxRegion and wxWindow
+// ----------------------------------------------------------------------------
+
+WX_DECLARE_LIST(wxRect, wxRectList);
+
 
 enum wxRegionContain {
        wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
@@ -104,6 +108,16 @@ public:
 
     // Get the internal Region handle
     WXRegion GetXRegion() const;
+
+// 'Naughty' functions that allow wxWindows to use a list of rects
+// instead of the region, in certain circumstances (e.g. when
+// making a region out of the update rectangles).
+// These are used by wxPaintDC::wxPaintDC and wxRegionIterator::Reset.
+    bool UsingRects() const;
+    wxRect* GetRects();
+    int GetRectCount() const;
+    void SetRects(const wxRectList& rectList);
+    void SetRects(int count, const wxRect* rects);
 };
 
 class WXDLLEXPORT wxRegionIterator : public wxObject {
@@ -128,13 +142,13 @@ public:
        long GetWidth() const { return GetW(); }
        long GetH() const;
        long GetHeight() const { return GetH(); }
-    wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
+        wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
 
 private:
        long     m_current;
        long     m_numRects;
        wxRegion m_region;
-    wxRect*  m_rects;
+        wxRect*  m_rects;
 };
 
 #endif
index 77b8625430978162e10b1b57cd3f3b16e8a3fffd..fbb7b729e9def8e1523838bb5cb462c3dca5c7c8 100644 (file)
     #pragma interface "window.h"
 #endif
 
-// ----------------------------------------------------------------------------
-// A list of rectangles type used by wxWindow
-// ----------------------------------------------------------------------------
-
-WX_DECLARE_LIST(wxRect, wxRectList);
+#include "wx/region.h"
 
 // ----------------------------------------------------------------------------
 // wxWindow class for Motif - see also wxWindowBase
index 560eee9c2b3044d37450a334e53fb09cb9ae1628..a0636f159b306fa91aeecbf263c0785c3074f1ca 100644 (file)
@@ -288,9 +288,11 @@ void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
 {
     m_selection = m_listbox->GetSelection();
     m_stringSelection = m_listbox->GetStringSelection();
+    // TODO!
+#ifndef __WXMOTIF__
     if ( m_listbox->HasClientUntypedData() )
         SetClientData(m_listbox->GetClientData(m_selection));
-
+#endif
     EndModal(wxID_OK);
 }
 
@@ -298,8 +300,12 @@ void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
 {
     m_selection = m_listbox->GetSelection();
     m_stringSelection = m_listbox->GetStringSelection();
+
+    // TODO!
+#ifndef __WXMOTIF__
     if ( m_listbox->HasClientUntypedData() )
         SetClientData(m_listbox->GetClientData(m_selection));
+#endif
 
     EndModal(wxID_OK);
 }
index c013b9fe8b084363f6ec706deb62fde02ea244ff..42ad9258d7681ebaefea5d2e1f35a581bc016fe6 100644 (file)
@@ -2284,6 +2284,9 @@ wxPaintDC::wxPaintDC(wxWindow* win) : wxWindowDC(win)
 
     win->SetUpdateRegion(*region);
 
+    wxRegion& theRegion(win->GetUpdateRegion());
+    theRegion.SetRects(updateRects); // We also store in terms of rects, for iteration to work.
+
     // Set the clipping region. Any user-defined region will be combined with this
     // one in SetDCClipping.
     XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
index 8431d309fafd61cec0b0d3e4a183ec957384843f..8b03f1052b89c4d04626d68ed6a1b3a49c6bfb01 100644 (file)
     IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
 #endif
 
+// ----------------------------------------------------------------------------
+// list types
+// ----------------------------------------------------------------------------
+
+#include "wx/listimpl.cpp"
+
+WX_DEFINE_LIST(wxRectList);
+
 //-----------------------------------------------------------------------------
 // wxRegionRefData implementation
 //-----------------------------------------------------------------------------
@@ -32,21 +40,86 @@ public:
     wxRegionRefData()
     {
         m_region = XCreateRegion();
+        m_usingRects = FALSE;
+        m_rects = (wxRect*) NULL;
+        m_rectCount = 0;
     }
 
     wxRegionRefData(const wxRegionRefData& data)
     {
         m_region = XCreateRegion();
+        m_rects = (wxRect*) NULL;
+        m_rectCount = 0;
         XUnionRegion(m_region, data.m_region, m_region);
+
+        SetRects(data.m_rectCount, data.m_rects);
     }
 
     ~wxRegionRefData()
     {
         XDestroyRegion(m_region);
+        DeleteRects();
     }
-    Region  m_region;
+
+    wxRect* GetRects() { return m_rects; };
+    void SetRects(const wxRectList& rectList);
+    void SetRects(int count, const wxRect* rects);
+    bool UsingRects() const { return m_usingRects; }
+    int GetRectCount() const { return m_rectCount; }
+
+    void DeleteRects();
+
+    Region      m_region;
+    wxRect*     m_rects;
+    int         m_rectCount;
+    bool        m_usingRects;  // TRUE if we're using the above.
 };
 
+void wxRegionRefData::SetRects(const wxRectList& rectList)
+{
+    DeleteRects();
+    m_usingRects = (rectList.Number() > 0);
+    if (m_usingRects)
+    {
+      m_rectCount = rectList.Number();
+      m_rects = new wxRect[m_rectCount];
+    }
+
+    wxRectList::Node* node = rectList.GetFirst();
+    int i = 0;
+    while (node) {
+        wxRect* rect = node->GetData();
+        m_rects[i] = * rect;
+        node = node->GetNext();
+        i ++;
+    }
+}
+
+void wxRegionRefData::SetRects(int count, const wxRect* rects)
+{
+    DeleteRects();
+    m_usingRects = (count > 0);
+    if (m_usingRects)
+    {
+      m_rectCount = count;
+      m_rects = new wxRect[m_rectCount];
+      int i;
+      for (i = 0; i < m_rectCount; i++)
+        m_rects[i] = rects[i];
+    }
+}
+
+void wxRegionRefData::DeleteRects()
+{
+   if (m_rects)
+   {
+      delete[] m_rects;
+      m_rects = (wxRect*) NULL;
+   }
+   m_rectCount = 0;
+   m_usingRects = FALSE;
+ }
+
 #define M_REGION (((wxRegionRefData*)m_refData)->m_region)
 
 //-----------------------------------------------------------------------------
@@ -296,6 +369,38 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const
     return Contains(x, y, w, h);
 }
 
+bool wxRegion::UsingRects() const
+{
+    return ((wxRegionRefData*)m_refData)->UsingRects();
+}
+
+/*
+wxRectList& wxRegion::GetRectList()
+{
+    return ((wxRegionRefData*)m_refData)->GetRectList();
+}
+*/
+
+wxRect* wxRegion::GetRects()
+{
+    return ((wxRegionRefData*)m_refData)->GetRects();
+}
+
+int wxRegion::GetRectCount() const
+{
+    return ((wxRegionRefData*)m_refData)->GetRectCount();
+}
+
+void wxRegion::SetRects(const wxRectList& rectList)
+{
+    ((wxRegionRefData*)m_refData)->SetRects(rectList);
+}
+
+void wxRegion::SetRects(int count, const wxRect* rects)
+{
+    ((wxRegionRefData*)m_refData)->SetRects(count, rects);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                             //
 //                               wxRegionIterator                                 //
@@ -342,12 +447,39 @@ void wxRegionIterator::Reset(const wxRegion& region)
         m_numRects = 0;
     else
     {
-        // TODO create m_rects and fill with rectangles for this region
-
-        // For now, fudge by getting the whole bounding box.
-        m_rects = new wxRect[1];
-        m_numRects = 1;
-        m_rects[0] = m_region.GetBox();
+        // Create m_rects and fill with rectangles for this region.
+        // Since we can't find the rectangles in a region, we cheat
+        // by retrieving the rectangles explicitly set in wxPaintDC::wxPaintDC
+        // (dcclient.cpp).
+        if (m_region.UsingRects())
+        {
+            wxRect* rects = m_region.GetRects();
+            int count = m_region.GetRectCount();
+            m_numRects = count;
+            m_rects = new wxRect[m_numRects];
+
+            int i = 0;
+            for (i = 0; i < m_numRects; i++)
+               m_rects[i] = rects[i];
+
+           /*
+            int i = 0;
+            wxRectList::Node* node = rectList.GetFirst();
+            while (node) {
+                wxRect* rect = node->GetData();
+                m_rects[i] = * rect;
+                node = node->GetNext();
+                i ++;
+            }
+           */
+        }
+        else
+        {
+            // For now, fudge by getting the whole bounding box.
+            m_rects = new wxRect[1];
+            m_numRects = 1;
+            m_rects[0] = m_region.GetBox();
+        }
     }
 }
 
index eb96d7f64566fe350c982e0898d86426a2dc98b6..0959d93286fffd8195c1c65ea24888c5fb0794c7 100644 (file)
@@ -40,8 +40,6 @@
 #include "wx/menuitem.h"
 #include "wx/log.h"
 
-#include "wx/listimpl.cpp"
-
 #if  wxUSE_DRAG_AND_DROP
     #include "wx/dnd.h"
 #endif
@@ -129,12 +127,6 @@ static int str16len(const char *s)
 // implementation
 // ============================================================================
 
-// ----------------------------------------------------------------------------
-// list types
-// ----------------------------------------------------------------------------
-
-WX_DEFINE_LIST(wxRectList);
-
 // ----------------------------------------------------------------------------
 // helper functions
 // ----------------------------------------------------------------------------