Fixed wxMotif's wxRegion/wxRegionIterator to optionally use wxRects.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
52068ea5ff
commit
25f4712757
@ -125,8 +125,6 @@ include/wx/html/msw/*.ico
|
|||||||
include/wx/html/msw/*.rc
|
include/wx/html/msw/*.rc
|
||||||
lib/dummy
|
lib/dummy
|
||||||
|
|
||||||
bin/*.*
|
|
||||||
|
|
||||||
tools/gettext/*.*
|
tools/gettext/*.*
|
||||||
|
|
||||||
bitmaps/xpm/16x16/*.*
|
bitmaps/xpm/16x16/*.*
|
||||||
|
@ -206,6 +206,7 @@ For printing-related dialogs, see the printing sample.
|
|||||||
using wxFrame.
|
using wxFrame.
|
||||||
<li><a href="../../samples/docvwmdi">docvwmdi</a>: : demonstrates use of the document view classes,
|
<li><a href="../../samples/docvwmdi">docvwmdi</a>: : demonstrates use of the document view classes,
|
||||||
using wxMDIParentFrame, wxMDIChildFrame.
|
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
|
<li><a href="../../samples/dynamic">dynamic</a>: shows how to connect events to member functions
|
||||||
dynamically.
|
dynamically.
|
||||||
<li><a href="../../samples/forty">forty</a>: a great little card game by Chris Breeze. A
|
<li><a href="../../samples/forty">forty</a>: a great little card game by Chris Breeze. A
|
||||||
|
@ -20,8 +20,12 @@
|
|||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
#include "wx/gdicmn.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 {
|
enum wxRegionContain {
|
||||||
wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
|
wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
|
||||||
@ -104,6 +108,16 @@ public:
|
|||||||
|
|
||||||
// Get the internal Region handle
|
// Get the internal Region handle
|
||||||
WXRegion GetXRegion() const;
|
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 {
|
class WXDLLEXPORT wxRegionIterator : public wxObject {
|
||||||
@ -128,13 +142,13 @@ public:
|
|||||||
long GetWidth() const { return GetW(); }
|
long GetWidth() const { return GetW(); }
|
||||||
long GetH() const;
|
long GetH() const;
|
||||||
long GetHeight() const { return GetH(); }
|
long GetHeight() const { return GetH(); }
|
||||||
wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
|
wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long m_current;
|
long m_current;
|
||||||
long m_numRects;
|
long m_numRects;
|
||||||
wxRegion m_region;
|
wxRegion m_region;
|
||||||
wxRect* m_rects;
|
wxRect* m_rects;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,11 +16,7 @@
|
|||||||
#pragma interface "window.h"
|
#pragma interface "window.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
#include "wx/region.h"
|
||||||
// A list of rectangles type used by wxWindow
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
WX_DECLARE_LIST(wxRect, wxRectList);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxWindow class for Motif - see also wxWindowBase
|
// wxWindow class for Motif - see also wxWindowBase
|
||||||
|
@ -288,9 +288,11 @@ void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
m_selection = m_listbox->GetSelection();
|
m_selection = m_listbox->GetSelection();
|
||||||
m_stringSelection = m_listbox->GetStringSelection();
|
m_stringSelection = m_listbox->GetStringSelection();
|
||||||
|
// TODO!
|
||||||
|
#ifndef __WXMOTIF__
|
||||||
if ( m_listbox->HasClientUntypedData() )
|
if ( m_listbox->HasClientUntypedData() )
|
||||||
SetClientData(m_listbox->GetClientData(m_selection));
|
SetClientData(m_listbox->GetClientData(m_selection));
|
||||||
|
#endif
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,8 +300,12 @@ void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
m_selection = m_listbox->GetSelection();
|
m_selection = m_listbox->GetSelection();
|
||||||
m_stringSelection = m_listbox->GetStringSelection();
|
m_stringSelection = m_listbox->GetStringSelection();
|
||||||
|
|
||||||
|
// TODO!
|
||||||
|
#ifndef __WXMOTIF__
|
||||||
if ( m_listbox->HasClientUntypedData() )
|
if ( m_listbox->HasClientUntypedData() )
|
||||||
SetClientData(m_listbox->GetClientData(m_selection));
|
SetClientData(m_listbox->GetClientData(m_selection));
|
||||||
|
#endif
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
|
@ -2284,6 +2284,9 @@ wxPaintDC::wxPaintDC(wxWindow* win) : wxWindowDC(win)
|
|||||||
|
|
||||||
win->SetUpdateRegion(*region);
|
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
|
// Set the clipping region. Any user-defined region will be combined with this
|
||||||
// one in SetDCClipping.
|
// one in SetDCClipping.
|
||||||
XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
|
XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
|
||||||
|
@ -23,6 +23,14 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// list types
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "wx/listimpl.cpp"
|
||||||
|
|
||||||
|
WX_DEFINE_LIST(wxRectList);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxRegionRefData implementation
|
// wxRegionRefData implementation
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -32,21 +40,86 @@ public:
|
|||||||
wxRegionRefData()
|
wxRegionRefData()
|
||||||
{
|
{
|
||||||
m_region = XCreateRegion();
|
m_region = XCreateRegion();
|
||||||
|
m_usingRects = FALSE;
|
||||||
|
m_rects = (wxRect*) NULL;
|
||||||
|
m_rectCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegionRefData(const wxRegionRefData& data)
|
wxRegionRefData(const wxRegionRefData& data)
|
||||||
{
|
{
|
||||||
m_region = XCreateRegion();
|
m_region = XCreateRegion();
|
||||||
|
m_rects = (wxRect*) NULL;
|
||||||
|
m_rectCount = 0;
|
||||||
XUnionRegion(m_region, data.m_region, m_region);
|
XUnionRegion(m_region, data.m_region, m_region);
|
||||||
|
|
||||||
|
SetRects(data.m_rectCount, data.m_rects);
|
||||||
}
|
}
|
||||||
|
|
||||||
~wxRegionRefData()
|
~wxRegionRefData()
|
||||||
{
|
{
|
||||||
XDestroyRegion(m_region);
|
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)
|
#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);
|
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 //
|
// wxRegionIterator //
|
||||||
@ -342,12 +447,39 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
|||||||
m_numRects = 0;
|
m_numRects = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO create m_rects and fill with rectangles for this region
|
// 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];
|
||||||
|
|
||||||
// For now, fudge by getting the whole bounding box.
|
int i = 0;
|
||||||
m_rects = new wxRect[1];
|
for (i = 0; i < m_numRects; i++)
|
||||||
m_numRects = 1;
|
m_rects[i] = rects[i];
|
||||||
m_rects[0] = m_region.GetBox();
|
|
||||||
|
/*
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@
|
|||||||
#include "wx/menuitem.h"
|
#include "wx/menuitem.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
#include "wx/listimpl.cpp"
|
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
#include "wx/dnd.h"
|
#include "wx/dnd.h"
|
||||||
#endif
|
#endif
|
||||||
@ -129,12 +127,6 @@ static int str16len(const char *s)
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// list types
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
WX_DEFINE_LIST(wxRectList);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// helper functions
|
// helper functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user