This commit is contained in:
JulianSmart
2016-07-14 15:29:16 +01:00
16 changed files with 297 additions and 74 deletions

View File

@@ -101,6 +101,7 @@ wxGTK:
- Support background colour in wxDataViewCtrl attributes. - Support background colour in wxDataViewCtrl attributes.
- Improve wxSpinCtrl best size calculation. - Improve wxSpinCtrl best size calculation.
- Implement support for icon locations in wxMimeTypesManager (Hanmac). - Implement support for icon locations in wxMimeTypesManager (Hanmac).
- Cosmetic fix for empty wxCheckBoxes display (Chuddah).
wxMSW: wxMSW:

View File

@@ -449,13 +449,13 @@ public:
DoGetSize(&dcWidth, &dcHeight); DoGetSize(&dcWidth, &dcHeight);
if ( x ) if ( x )
*x = m_clipping ? m_clipX1 : 0; *x = m_clipping ? m_clipX1 : DeviceToLogicalX(0);
if ( y ) if ( y )
*y = m_clipping ? m_clipY1 : 0; *y = m_clipping ? m_clipY1 : DeviceToLogicalY(0);
if ( w ) if ( w )
*w = m_clipping ? m_clipX2 - m_clipX1 : dcWidth; *w = m_clipping ? m_clipX2 - m_clipX1 : DeviceToLogicalXRel(dcWidth);
if ( h ) if ( h )
*h = m_clipping ? m_clipY2 - m_clipY1 : dcHeight; *h = m_clipping ? m_clipY2 - m_clipY1 : DeviceToLogicalYRel(dcHeight);
} }
virtual void DestroyClippingRegion() { ResetClipping(); } virtual void DestroyClippingRegion() { ResetClipping(); }

View File

@@ -1527,8 +1527,8 @@ public:
// Hides or reveals the property. // Hides or reveals the property.
// hide - true for hide, false for reveal. // hide - true for hide, false for reveal.
// flags - By default changes are applied recursively. Set this paramter // flags - By default changes are applied recursively. Set this
// wxPG_DONT_RECURSE to prevent this. // parameter to wxPG_DONT_RECURSE to prevent this.
bool Hide( bool hide, int flags = wxPG_RECURSE ); bool Hide( bool hide, int flags = wxPG_RECURSE );
// Returns true if property has visible children. // Returns true if property has visible children.

View File

@@ -317,34 +317,38 @@ WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxObject*, wxArrayPGObject,
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
enum wxPG_GETPROPERTYVALUES_FLAGS enum wxPG_PROPERTYVALUES_FLAGS
{ {
// Flag for wxPropertyGridInterface::SetProperty* functions,
// wxPropertyGridInterface::HideProperty(), etc.
// Apply changes only for the property in question.
wxPG_DONT_RECURSE = 0x00000000,
/** Flags for wxPropertyGridInterface::GetPropertyValues */ // Flag for wxPropertyGridInterface::GetPropertyValues().
// Use this flag to retain category structure; each sub-category
// will be its own wxVariantList of wxVariant.
wxPG_KEEP_STRUCTURE = 0x00000010, wxPG_KEEP_STRUCTURE = 0x00000010,
/** Flags for wxPropertyGrid::SetPropertyAttribute() etc */ // Flag for wxPropertyGridInterface::SetProperty* functions,
// wxPropertyGridInterface::HideProperty(), etc.
// Apply changes recursively for the property and all its children.
wxPG_RECURSE = 0x00000020, wxPG_RECURSE = 0x00000020,
/** Include attributes for GetPropertyValues. */ // Flag for wxPropertyGridInterface::GetPropertyValues().
// Use this flag to include property attributes as well.
wxPG_INC_ATTRIBUTES = 0x00000040, wxPG_INC_ATTRIBUTES = 0x00000040,
/** Used when first starting recursion. */ // Used when first starting recursion.
wxPG_RECURSE_STARTS = 0x00000080, wxPG_RECURSE_STARTS = 0x00000080,
/** Force value change. */ // Force value change.
wxPG_FORCE = 0x00000100, wxPG_FORCE = 0x00000100,
/** Only sort categories and their immediate children. // Only sort categories and their immediate children.
Sorting done by wxPG_AUTO_SORT option uses this. // Sorting done by wxPG_AUTO_SORT option uses this.
*/
wxPG_SORT_TOP_LEVEL_ONLY = 0x00000200 wxPG_SORT_TOP_LEVEL_ONLY = 0x00000200
}; };
/** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
#define wxPG_DONT_RECURSE 0x00000000
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Misc. argument flags. // Misc. argument flags.

View File

@@ -85,10 +85,22 @@ public:
bool IsKindOf(const wxClassInfo *info) const bool IsKindOf(const wxClassInfo *info) const
{ {
return info != 0 && if ( info == this )
( info == this || return true;
( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) ||
( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) ); if ( m_baseInfo1 )
{
if ( m_baseInfo1->IsKindOf(info) )
return true;
}
if ( m_baseInfo2 )
{
if ( m_baseInfo2->IsKindOf(info) )
return true;
}
return false;
} }
wxDECLARE_CLASS_INFO_ITERATORS(); wxDECLARE_CLASS_INFO_ITERATORS();

View File

@@ -1664,6 +1664,10 @@ public:
Default is wxPG_RECURSE which causes colour to be set recursively. Default is wxPG_RECURSE which causes colour to be set recursively.
Omit this flag to only set colour for the property in question Omit this flag to only set colour for the property in question
and not any of its children. and not any of its children.
@remarks
Unlike wxPropertyGridInterface::SetPropertyBackgroundColour(),
this does not automatically update the display.
*/ */
void SetBackgroundColour( const wxColour& colour, void SetBackgroundColour( const wxColour& colour,
int flags = wxPG_RECURSE ); int flags = wxPG_RECURSE );
@@ -1753,8 +1757,11 @@ public:
/** /**
Sets property's label. Sets property's label.
@remarks Properties under same parent may have same labels. However, @remarks
property names must still remain unique. - Properties under same parent may have same labels. However,
property names must still remain unique.
- Unlike wxPropertyGridInterface::SetPropertyLabel(),
this does not automatically update the display.
*/ */
void SetLabel( const wxString& label ); void SetLabel( const wxString& label );
@@ -1796,6 +1803,10 @@ public:
Default is wxPG_RECURSE which causes colour to be set recursively. Default is wxPG_RECURSE which causes colour to be set recursively.
Omit this flag to only set colour for the property in question Omit this flag to only set colour for the property in question
and not any of its children. and not any of its children.
@remarks
Unlike wxPropertyGridInterface::SetPropertyTextColour(),
this does not automatically update the display.
*/ */
void SetTextColour( const wxColour& colour, void SetTextColour( const wxColour& colour,
int flags = wxPG_RECURSE ); int flags = wxPG_RECURSE );
@@ -1807,6 +1818,10 @@ public:
Default is wxPG_RECURSE which causes colours to be set recursively. Default is wxPG_RECURSE which causes colours to be set recursively.
Omit this flag to only set colours for the property in question Omit this flag to only set colours for the property in question
and not any of its children. and not any of its children.
@remarks
Unlike wxPropertyGridInterface::SetPropertyColoursToDefault(),
this does not automatically update the display.
*/ */
void SetDefaultColours(int flags = wxPG_RECURSE); void SetDefaultColours(int flags = wxPG_RECURSE);

View File

@@ -6,6 +6,70 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/**
@section propgrid_property_values_attributes wxPropertyGrid Property Values Attribute Identifiers
Many wxPropertyGridInterface and wxPropertyGrid methods to set property
value or to modify its state use these flags to specify additional details
of the operation.
@{
*/
enum wxPG_PROPERTYVALUES_FLAGS
{
/**
Flag for wxPropertyGridInterface::SetProperty* functions,
wxPropertyGridInterface::HideProperty(), etc.
Apply changes only for the property in question.
@hideinitializer
*/
wxPG_DONT_RECURSE = 0x00000000,
/**
Flag for wxPropertyGridInterface::GetPropertyValues().
Use this flag to retain category structure; each sub-category
will be its own wxVariantList of wxVariant.
@hideinitializer
*/
wxPG_KEEP_STRUCTURE = 0x00000010,
/**
Flag for wxPropertyGridInterface::SetProperty* functions,
wxPropertyGridInterface::HideProperty(), etc.
Apply changes recursively for the property and all its children.
@hideinitializer
*/
wxPG_RECURSE = 0x00000020,
/**
Flag for wxPropertyGridInterface::GetPropertyValues().
Use this flag to include property attributes as well.
@hideinitializer
*/
wxPG_INC_ATTRIBUTES = 0x00000040,
/**
Used when first starting recursion.
@hideinitializer
*/
wxPG_RECURSE_STARTS = 0x00000080,
/**
Force value change.
@hideinitializer
*/
wxPG_FORCE = 0x00000100,
/**
Only sort categories and their immediate children.
Sorting done by wxPG_AUTO_SORT option uses this.
@hideinitializer
*/
wxPG_SORT_TOP_LEVEL_ONLY = 0x00000200
};
/** @}
*/
/** /**
@class wxPropertyGridInterface @class wxPropertyGridInterface
@@ -156,6 +220,9 @@ public:
/** /**
Disables a property. Disables a property.
@remarks
Property is refreshed with new settings.
@see EnableProperty(), wxPGProperty::Enable() @see EnableProperty(), wxPGProperty::Enable()
*/ */
bool DisableProperty( wxPGPropArg id ); bool DisableProperty( wxPGPropArg id );
@@ -176,6 +243,9 @@ public:
@param enable @param enable
If @false, property is disabled instead. If @false, property is disabled instead.
@remarks
Property is refreshed with new settings.
@see wxPGProperty::Enable() @see wxPGProperty::Enable()
*/ */
bool EnableProperty( wxPGPropArg id, bool enable = true ); bool EnableProperty( wxPGPropArg id, bool enable = true );
@@ -603,6 +673,9 @@ public:
/** /**
Disables (limit = @true) or enables (limit = @false) wxTextCtrl editor Disables (limit = @true) or enables (limit = @false) wxTextCtrl editor
of a property, if it is not the sole mean to edit the value. of a property, if it is not the sole mean to edit the value.
@remarks
Property is refreshed with new settings.
*/ */
void LimitPropertyEditing( wxPGPropArg id, bool limit = true ); void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
@@ -768,8 +841,10 @@ public:
Optional. Optional.
Use wxPG_RECURSE to set the attribute to child properties recursively. Use wxPG_RECURSE to set the attribute to child properties recursively.
@remarks Setting attribute's value to wxNullVariant will simply remove it @remarks
from property's set of attributes. - Setting attribute's value to wxNullVariant will simply remove it
from property's set of attributes.
- Property is refreshed with new settings.
*/ */
void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName,
wxVariant value, long argFlags = 0 ); wxVariant value, long argFlags = 0 );
@@ -778,11 +853,14 @@ public:
Sets property attribute for all applicapple properties. Sets property attribute for all applicapple properties.
Be sure to use this method only after all properties have been Be sure to use this method only after all properties have been
added to the grid. added to the grid.
@remarks
Properties are refreshed with new settings.
*/ */
void SetPropertyAttributeAll( const wxString& attrName, wxVariant value ); void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
/** /**
Sets background colour of a property. Sets background colour of given property.
@param id @param id
Property name or pointer. Property name or pointer.
@@ -794,6 +872,10 @@ public:
Default is wxPG_RECURSE which causes colour to be set recursively. Default is wxPG_RECURSE which causes colour to be set recursively.
Omit this flag to only set colour for the property in question Omit this flag to only set colour for the property in question
and not any of its children. and not any of its children.
@remarks
- If category is tried to set recursively, only its children are affected.
- Property is redrawn with new colour.
*/ */
void SetPropertyBackgroundColour( wxPGPropArg id, void SetPropertyBackgroundColour( wxPGPropArg id,
const wxColour& colour, const wxColour& colour,
@@ -823,12 +905,17 @@ public:
/** /**
Resets text and background colours of given property. Resets text and background colours of given property.
@param id @param id
Property name or pointer. Property name or pointer.
@param flags @param flags
Default is wxPG_DONT_RECURSE which causes colour to be reset Default is wxPG_DONT_RECURSE which causes colour to be reset
only for the property in question (for backward compatibility). only for the property in question (for backward compatibility).
@remarks
- If category is tried to set recursively, only its children are affected.
- Property is redrawn with new colours.
*/ */
void SetPropertyColoursToDefault(wxPGPropArg id, int flags = wxPG_DONT_RECURSE); void SetPropertyColoursToDefault(wxPGPropArg id, int flags = wxPG_DONT_RECURSE);
@@ -887,8 +974,10 @@ public:
By default changes are applied recursively. Set this parameter By default changes are applied recursively. Set this parameter
to wxPG_DONT_RECURSE to prevent this. to wxPG_DONT_RECURSE to prevent this.
@remarks This is mainly for use with textctrl editor. Only some other @remarks
editors fully support it. - This is mainly for use with textctrl editor. Only some other
editors fully support it.
- Property is refreshed with new settings.
*/ */
void SetPropertyReadOnly( wxPGPropArg id, bool set = true, void SetPropertyReadOnly( wxPGPropArg id, bool set = true,
int flags = wxPG_RECURSE ); int flags = wxPG_RECURSE );
@@ -936,18 +1025,22 @@ public:
/** /**
Sets text colour of a property. Sets text colour of given property.
@param id @param id
Property name or pointer. Property name or pointer.
@param colour @param colour
New background colour. New text colour.
@param flags @param flags
Default is wxPG_RECURSE which causes colour to be set recursively. Default is wxPG_RECURSE which causes colour to be set recursively.
Omit this flag to only set colour for the property in question Omit this flag to only set colour for the property in question
and not any of its children. and not any of its children.
@remarks
- If category is tried to set recursively, only its children are affected.
- Property is redrawn with new colour.
*/ */
void SetPropertyTextColour( wxPGPropArg id, void SetPropertyTextColour( wxPGPropArg id,
const wxColour& colour, const wxColour& colour,

View File

@@ -387,7 +387,8 @@ void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
// of required clipping box and DC surface. // of required clipping box and DC surface.
int dcWidth, dcHeight; int dcWidth, dcHeight;
DoGetSize(&dcWidth, &dcHeight); DoGetSize(&dcWidth, &dcHeight);
wxRect dcRect(wxSize(dcWidth, dcHeight)); wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0),
DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight));
clipRegion = dcRect.Intersect(newRegion); clipRegion = dcRect.Intersect(newRegion);
m_clipping = true; m_clipping = true;

View File

@@ -1151,9 +1151,10 @@ void wxGCDCImpl::Clear(void)
wxCompositionMode formerMode = m_graphicContext->GetCompositionMode(); wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE); m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE);
// maximum positive coordinate Cairo can handle is 2^23 - 1 // maximum positive coordinate Cairo can handle is 2^23 - 1
// Use a value slightly less than this to be sure we avoid the limit
DoDrawRectangle( DoDrawRectangle(
DeviceToLogicalX(0), DeviceToLogicalY(0), DeviceToLogicalX(0), DeviceToLogicalY(0),
DeviceToLogicalXRel(0x007fffff), DeviceToLogicalYRel(0x007fffff)); DeviceToLogicalXRel(0x800000 - 64), DeviceToLogicalYRel(0x800000 - 64));
m_graphicContext->SetCompositionMode(formerMode); m_graphicContext->SetCompositionMode(formerMode);
m_graphicContext->SetPen( m_pen ); m_graphicContext->SetPen( m_pen );
m_graphicContext->SetBrush( m_brush ); m_graphicContext->SetBrush( m_brush );

View File

@@ -82,7 +82,7 @@
#endif #endif
// TODO: Borland probably has _wgetcwd as well? // TODO: Borland probably has _wgetcwd as well?
#ifdef _MSC_VER #if defined(_MSC_VER) || defined(__MINGW32__)
#define HAVE_WGETCWD #define HAVE_WGETCWD
#endif #endif

View File

@@ -1171,7 +1171,7 @@ wxString wxStripMenuCodes(const wxString& in, int flags)
} }
// The initial '?' means we match "Foo(&F)" but not "(&F)" // The initial '?' means we match "Foo(&F)" but not "(&F)"
if (label.Matches("?*(&?)") > 0) if (label.Matches("?*(&?)"))
{ {
label = label.Left( label.Len()-4 ).Trim(); label = label.Left( label.Len()-4 ).Trim();
return label + accel; return label + accel;

View File

@@ -204,6 +204,13 @@ void wxCheckBox::SetLabel( const wxString& label )
{ {
wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") ); wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") );
// If we don't hide the empty label, in some themes a focus rectangle is
// still drawn around it and this looks out of place.
if ( label.empty() )
gtk_widget_hide(m_widgetLabel);
else
gtk_widget_show(m_widgetLabel);
// save the label inside m_label in case user calls GetLabel() later // save the label inside m_label in case user calls GetLabel() later
wxControl::SetLabel(label); wxControl::SetLabel(label);

View File

@@ -709,30 +709,19 @@ int wxMSWDCImpl::GetDepth() const
void wxMSWDCImpl::Clear() void wxMSWDCImpl::Clear()
{ {
RECT rect; if ( !m_window )
if (m_window)
{
GetClientRect((HWND) m_window->GetHWND(), &rect);
}
else
{ {
// No, I think we should simply ignore this if printing on e.g. // No, I think we should simply ignore this if printing on e.g.
// a printer DC. // a printer DC.
// wxCHECK_RET( m_selectedBitmap.IsOk(), wxT("this DC can't be cleared") ); // wxCHECK_RET( m_selectedBitmap.IsOk(), wxT("this DC can't be cleared") );
if (!m_selectedBitmap.IsOk()) if (!m_selectedBitmap.IsOk())
return; return;
rect.left = rect.top = 0;
rect.right = m_selectedBitmap.GetWidth();
rect.bottom = m_selectedBitmap.GetHeight();
} }
::OffsetRect(&rect, -m_deviceOriginX, -m_deviceOriginY);
(void) ::SetMapMode(GetHdc(), MM_TEXT);
DWORD colour = ::GetBkColor(GetHdc()); DWORD colour = ::GetBkColor(GetHdc());
HBRUSH brush = ::CreateSolidBrush(colour); HBRUSH brush = ::CreateSolidBrush(colour);
RECT rect;
::GetClipBox(GetHdc(), &rect);
::FillRect(GetHdc(), &rect, brush); ::FillRect(GetHdc(), &rect, brush);
::DeleteObject(brush); ::DeleteObject(brush);

View File

@@ -279,9 +279,19 @@ void wxPropertyGridInterface::SetPropertyReadOnly( wxPGPropArg id, bool set, int
wxPG_PROP_ARG_CALL_PROLOG() wxPG_PROP_ARG_CALL_PROLOG()
if ( flags & wxPG_RECURSE ) if ( flags & wxPG_RECURSE )
{
p->SetFlagRecursively(wxPG_PROP_READONLY, set); p->SetFlagRecursively(wxPG_PROP_READONLY, set);
}
else else
{
// Do nothing if flag is already set as required.
if ( set && p->HasFlag(wxPG_PROP_READONLY) )
return;
if ( !set && !p->HasFlag(wxPG_PROP_READONLY) )
return;
p->ChangeFlag(wxPG_PROP_READONLY, set); p->ChangeFlag(wxPG_PROP_READONLY, set);
}
wxPropertyGridPageState* state = p->GetParentState(); wxPropertyGridPageState* state = p->GetParentState();
if( state ) if( state )
@@ -557,6 +567,15 @@ bool wxPropertyGridInterface::HideProperty( wxPGPropArg id, bool hide, int flags
{ {
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
// Do nothing if single property is already hidden/visible as requested.
if ( !(flags & wxPG_RECURSE) )
{
if ( hide && p->HasFlag(wxPG_PROP_HIDDEN) )
return false;
if ( !hide && !p->HasFlag(wxPG_PROP_HIDDEN) )
return false;
}
wxPropertyGrid* pg = m_pState->GetGrid(); wxPropertyGrid* pg = m_pState->GetGrid();
if ( pg == p->GetGrid() ) if ( pg == p->GetGrid() )
@@ -618,6 +637,9 @@ void wxPropertyGridInterface::SetPropertyLabel( wxPGPropArg id, const wxString&
{ {
wxPG_PROP_ARG_CALL_PROLOG() wxPG_PROP_ARG_CALL_PROLOG()
if ( p->GetLabel() == newproplabel )
return;
p->SetLabel( newproplabel ); p->SetLabel( newproplabel );
wxPropertyGridPageState* state = p->GetParentState(); wxPropertyGridPageState* state = p->GetParentState();
@@ -629,9 +651,19 @@ void wxPropertyGridInterface::SetPropertyLabel( wxPGPropArg id, const wxString&
if ( pg->GetState() == state ) if ( pg->GetState() == state )
{ {
if ( pg->HasFlag(wxPG_AUTO_SORT) ) if ( pg->HasFlag(wxPG_AUTO_SORT) )
{
pg->Refresh(); pg->Refresh();
// If any property is selected it has to
// be refreshed in the new location.
if ( pg == p->GetGrid() && pg->GetSelectedProperty() )
{
RefreshProperty(pg->GetSelectedProperty());
}
}
else else
{
pg->DrawItem( p ); pg->DrawItem( p );
}
} }
} }
@@ -669,7 +701,16 @@ wxPropertyGridInterface::SetPropertyBackgroundColour( wxPGPropArg id,
{ {
wxPG_PROP_ARG_CALL_PROLOG() wxPG_PROP_ARG_CALL_PROLOG()
p->SetBackgroundColour(colour, flags); p->SetBackgroundColour(colour, flags);
RefreshProperty(p);
// Redraw the control
wxPropertyGrid* pg = m_pState->GetGrid();
if ( pg == p->GetGrid() )
{
if ( flags & wxPG_RECURSE )
pg->DrawItemAndChildren(p);
else
pg->DrawItem(p);
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -680,7 +721,16 @@ void wxPropertyGridInterface::SetPropertyTextColour( wxPGPropArg id,
{ {
wxPG_PROP_ARG_CALL_PROLOG() wxPG_PROP_ARG_CALL_PROLOG()
p->SetTextColour(colour, flags); p->SetTextColour(colour, flags);
RefreshProperty(p);
// Redraw the control
wxPropertyGrid* pg = m_pState->GetGrid();
if ( pg == p->GetGrid() )
{
if ( flags & wxPG_RECURSE )
pg->DrawItemAndChildren(p);
else
pg->DrawItem(p);
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -695,8 +745,17 @@ void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id)
void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id, int flags) void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id, int flags)
{ {
wxPG_PROP_ARG_CALL_PROLOG() wxPG_PROP_ARG_CALL_PROLOG()
p->SetDefaultColours(flags); p->SetDefaultColours(flags);
// Redraw the control
wxPropertyGrid* pg = m_pState->GetGrid();
if ( pg == p->GetGrid() )
{
if ( flags & wxPG_RECURSE )
pg->DrawItemAndChildren(p);
else
pg->DrawItem(p);
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@@ -27,7 +27,7 @@
// test class // test class
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static const wxSize s_dcSize(100, 105); static const wxSize s_dcSize(100, 120);
static const wxColour s_bgColour(*wxWHITE); // colour to draw outside clipping box static const wxColour s_bgColour(*wxWHITE); // colour to draw outside clipping box
static const wxColour s_fgColour(*wxGREEN); // colour to draw inside clipping box static const wxColour s_fgColour(*wxGREEN); // colour to draw inside clipping box
@@ -52,12 +52,14 @@ private:
protected: protected:
void InitialState(); void InitialState();
void InitialStateWithTransformedDC();
void OneRegion(); void OneRegion();
void OneLargeRegion(); void OneLargeRegion();
void OneOuterRegion(); void OneOuterRegion();
void OneRegionNegDim(); void OneRegionNegDim();
void OneRegionAndReset(); void OneRegionAndReset();
void OneRegionAndEmpty(); void OneRegionAndEmpty();
void OneRegionWithTransformedDC();
void TwoRegionsOverlapping(); void TwoRegionsOverlapping();
void TwoRegionsOverlappingNegDim(); void TwoRegionsOverlappingNegDim();
void TwoRegionsNonOverlapping(); void TwoRegionsNonOverlapping();
@@ -100,12 +102,14 @@ public:
private: private:
CPPUNIT_TEST_SUITE( ClippingBoxTestCaseDC ); CPPUNIT_TEST_SUITE( ClippingBoxTestCaseDC );
CPPUNIT_TEST( InitialState ); CPPUNIT_TEST( InitialState );
CPPUNIT_TEST( InitialStateWithTransformedDC );
CPPUNIT_TEST( OneRegion ); CPPUNIT_TEST( OneRegion );
CPPUNIT_TEST( OneLargeRegion ); CPPUNIT_TEST( OneLargeRegion );
CPPUNIT_TEST( OneOuterRegion ); CPPUNIT_TEST( OneOuterRegion );
CPPUNIT_TEST( OneRegionNegDim ); CPPUNIT_TEST( OneRegionNegDim );
CPPUNIT_TEST( OneRegionAndReset ); CPPUNIT_TEST( OneRegionAndReset );
CPPUNIT_TEST( OneRegionAndEmpty ); CPPUNIT_TEST( OneRegionAndEmpty );
CPPUNIT_TEST( OneRegionWithTransformedDC );
CPPUNIT_TEST( TwoRegionsOverlapping ); CPPUNIT_TEST( TwoRegionsOverlapping );
CPPUNIT_TEST( TwoRegionsOverlappingNegDim ); CPPUNIT_TEST( TwoRegionsOverlappingNegDim );
CPPUNIT_TEST( TwoRegionsNonOverlapping ); CPPUNIT_TEST( TwoRegionsNonOverlapping );
@@ -161,12 +165,14 @@ public:
private: private:
CPPUNIT_TEST_SUITE( ClippingBoxTestCaseGCDC ); CPPUNIT_TEST_SUITE( ClippingBoxTestCaseGCDC );
CPPUNIT_TEST( InitialState ); CPPUNIT_TEST( InitialState );
CPPUNIT_TEST( InitialStateWithTransformedDC );
CPPUNIT_TEST( OneRegion ); CPPUNIT_TEST( OneRegion );
CPPUNIT_TEST( OneLargeRegion ); CPPUNIT_TEST( OneLargeRegion );
CPPUNIT_TEST( OneOuterRegion ); CPPUNIT_TEST( OneOuterRegion );
CPPUNIT_TEST( OneRegionNegDim ); CPPUNIT_TEST( OneRegionNegDim );
CPPUNIT_TEST( OneRegionAndReset ); CPPUNIT_TEST( OneRegionAndReset );
CPPUNIT_TEST( OneRegionAndEmpty ); CPPUNIT_TEST( OneRegionAndEmpty );
CPPUNIT_TEST( OneRegionWithTransformedDC );
CPPUNIT_TEST( TwoRegionsOverlapping ); CPPUNIT_TEST( TwoRegionsOverlapping );
CPPUNIT_TEST( TwoRegionsOverlappingNegDim ); CPPUNIT_TEST( TwoRegionsOverlappingNegDim );
CPPUNIT_TEST( TwoRegionsNonOverlapping ); CPPUNIT_TEST( TwoRegionsNonOverlapping );
@@ -208,12 +214,14 @@ public:
private: private:
CPPUNIT_TEST_SUITE( ClippingBoxTestCaseGDIPlus ); CPPUNIT_TEST_SUITE( ClippingBoxTestCaseGDIPlus );
CPPUNIT_TEST( InitialState ); CPPUNIT_TEST( InitialState );
CPPUNIT_TEST( InitialStateWithTransformedDC );
CPPUNIT_TEST( OneRegion ); CPPUNIT_TEST( OneRegion );
CPPUNIT_TEST( OneLargeRegion ); CPPUNIT_TEST( OneLargeRegion );
CPPUNIT_TEST( OneOuterRegion ); CPPUNIT_TEST( OneOuterRegion );
CPPUNIT_TEST( OneRegionNegDim ); CPPUNIT_TEST( OneRegionNegDim );
CPPUNIT_TEST( OneRegionAndReset ); CPPUNIT_TEST( OneRegionAndReset );
CPPUNIT_TEST( OneRegionAndEmpty ); CPPUNIT_TEST( OneRegionAndEmpty );
CPPUNIT_TEST( OneRegionWithTransformedDC );
CPPUNIT_TEST( TwoRegionsOverlapping ); CPPUNIT_TEST( TwoRegionsOverlapping );
CPPUNIT_TEST( TwoRegionsOverlappingNegDim ); CPPUNIT_TEST( TwoRegionsOverlappingNegDim );
CPPUNIT_TEST( TwoRegionsNonOverlapping ); CPPUNIT_TEST( TwoRegionsNonOverlapping );
@@ -259,12 +267,14 @@ public:
private: private:
CPPUNIT_TEST_SUITE( ClippingBoxTestCaseDirect2D ); CPPUNIT_TEST_SUITE( ClippingBoxTestCaseDirect2D );
CPPUNIT_TEST( InitialState ); CPPUNIT_TEST( InitialState );
CPPUNIT_TEST( InitialStateWithTransformedDC );
CPPUNIT_TEST( OneRegion ); CPPUNIT_TEST( OneRegion );
CPPUNIT_TEST( OneLargeRegion ); CPPUNIT_TEST( OneLargeRegion );
CPPUNIT_TEST( OneOuterRegion ); CPPUNIT_TEST( OneOuterRegion );
CPPUNIT_TEST( OneRegionNegDim ); CPPUNIT_TEST( OneRegionNegDim );
CPPUNIT_TEST( OneRegionAndReset ); CPPUNIT_TEST( OneRegionAndReset );
CPPUNIT_TEST( OneRegionAndEmpty ); CPPUNIT_TEST( OneRegionAndEmpty );
CPPUNIT_TEST( OneRegionWithTransformedDC );
CPPUNIT_TEST( TwoRegionsOverlapping ); CPPUNIT_TEST( TwoRegionsOverlapping );
CPPUNIT_TEST( TwoRegionsOverlappingNegDim ); CPPUNIT_TEST( TwoRegionsOverlappingNegDim );
CPPUNIT_TEST( TwoRegionsNonOverlapping ); CPPUNIT_TEST( TwoRegionsNonOverlapping );
@@ -302,12 +312,14 @@ public:
private: private:
CPPUNIT_TEST_SUITE( ClippingBoxTestCaseCairo ); CPPUNIT_TEST_SUITE( ClippingBoxTestCaseCairo );
CPPUNIT_TEST( InitialState ); CPPUNIT_TEST( InitialState );
CPPUNIT_TEST( InitialStateWithTransformedDC );
CPPUNIT_TEST( OneRegion ); CPPUNIT_TEST( OneRegion );
CPPUNIT_TEST( OneLargeRegion ); CPPUNIT_TEST( OneLargeRegion );
CPPUNIT_TEST( OneOuterRegion ); CPPUNIT_TEST( OneOuterRegion );
CPPUNIT_TEST( OneRegionNegDim ); CPPUNIT_TEST( OneRegionNegDim );
CPPUNIT_TEST( OneRegionAndReset ); CPPUNIT_TEST( OneRegionAndReset );
CPPUNIT_TEST( OneRegionAndEmpty ); CPPUNIT_TEST( OneRegionAndEmpty );
CPPUNIT_TEST( OneRegionWithTransformedDC );
CPPUNIT_TEST( TwoRegionsOverlapping ); CPPUNIT_TEST( TwoRegionsOverlapping );
CPPUNIT_TEST( TwoRegionsOverlappingNegDim ); CPPUNIT_TEST( TwoRegionsOverlappingNegDim );
CPPUNIT_TEST( TwoRegionsNonOverlapping ); CPPUNIT_TEST( TwoRegionsNonOverlapping );
@@ -367,17 +379,26 @@ void ClippingBoxTestCaseBase::CheckBox(int x, int y, int width, int height)
msg = msgDim; msg = msgDim;
} }
// We will examine pixels directly in the underlying bitmap
// so we need to get device coordinates of examined area.
x = m_dc->LogicalToDeviceX(x);
y = m_dc->LogicalToDeviceY(y);
width = m_dc->LogicalToDeviceXRel(width);
height = m_dc->LogicalToDeviceYRel(height);
// Update wxDC contents. // Update wxDC contents.
FlushDC(); FlushDC();
// Check whether diagonal corners of the clipping box // Check whether diagonal corners of the clipping box
// are actually drawn at the edge of the clipping region. // are actually drawn at the edge of the clipping region.
#if wxUSE_IMAGE #if wxUSE_IMAGE
// For some renderers is's not possible to get pixels // For some renderers it's not possible to get pixels
// value from wxDC so we would have to examine pixels // value from wxDC so we would have to examine pixels
// in the underlying bitmap. // in the underlying bitmap.
wxImage img; wxImage img;
img = m_bmp.ConvertToImage(); img = m_bmp.ConvertToImage();
#else
return;
#endif // wxUSE_IMAGE #endif // wxUSE_IMAGE
// Check area near the top-left corner // Check area near the top-left corner
@@ -394,18 +415,15 @@ void ClippingBoxTestCaseBase::CheckBox(int x, int y, int width, int height)
for( int px = xmin; px <= xmax; px++ ) for( int px = xmin; px <= xmax; px++ )
{ {
wxColour c; wxColour c;
if ( !m_dc->GetPixel(px, py, &c) )
{
#if wxUSE_IMAGE #if wxUSE_IMAGE
unsigned char r = img.GetRed(px, py); unsigned char r = img.GetRed(px, py);
unsigned char g = img.GetGreen(px, py); unsigned char g = img.GetGreen(px, py);
unsigned char b = img.GetBlue(px, py); unsigned char b = img.GetBlue(px, py);
c.Set(r, g, b); c.Set(r, g, b);
#else #else
// We cannot get pixel value // We cannot get pixel value
break; break;
#endif // wxUSE_IMAGE / !wxUSE_IMAGE #endif // wxUSE_IMAGE / !wxUSE_IMAGE
}
wxString msgColour; wxString msgColour;
if ( px >= x && px <= x + (width-1) && if ( px >= x && px <= x + (width-1) &&
@@ -458,18 +476,15 @@ void ClippingBoxTestCaseBase::CheckBox(int x, int y, int width, int height)
for( int px = xmin; px <= xmax; px++ ) for( int px = xmin; px <= xmax; px++ )
{ {
wxColour c; wxColour c;
if ( !m_dc->GetPixel(px, py, &c) )
{
#if wxUSE_IMAGE #if wxUSE_IMAGE
unsigned char r = img.GetRed(px, py); unsigned char r = img.GetRed(px, py);
unsigned char g = img.GetGreen(px, py); unsigned char g = img.GetGreen(px, py);
unsigned char b = img.GetBlue(px, py); unsigned char b = img.GetBlue(px, py);
c.Set(r, g, b); c.Set(r, g, b);
#else #else
// We cannot get pixel value // We cannot get pixel value
break; break;
#endif // wxUSE_IMAGE / !wxUSE_IMAGE #endif // wxUSE_IMAGE / !wxUSE_IMAGE
}
wxString msgColour; wxString msgColour;
if ( px >= x && px <= x + (width-1) && if ( px >= x && px <= x + (width-1) &&
@@ -525,6 +540,18 @@ void ClippingBoxTestCaseBase::InitialState()
CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight()); CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight());
} }
void ClippingBoxTestCaseBase::InitialStateWithTransformedDC()
{
// Initial clipping box with transformed DC.
m_dc->SetDeviceOrigin(10, 15);
m_dc->SetUserScale(0.5, 1.5);
m_dc->SetLogicalScale(4.0, 2.0);
m_dc->SetLogicalOrigin(-15, -20);
m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID));
m_dc->Clear();
CheckBox(-20, -25, 50, 40);
}
void ClippingBoxTestCaseBase::OneRegion() void ClippingBoxTestCaseBase::OneRegion()
{ {
// Setting one clipping box inside DC area. // Setting one clipping box inside DC area.
@@ -587,6 +614,20 @@ void ClippingBoxTestCaseBase::OneRegionAndEmpty()
CheckBox(0, 0, 0, 0); CheckBox(0, 0, 0, 0);
} }
void ClippingBoxTestCaseBase::OneRegionWithTransformedDC()
{
// Setting one clipping box inside DC area
// with applied some transformations.
m_dc->SetDeviceOrigin(10, 15);
m_dc->SetUserScale(0.5, 1.5);
m_dc->SetLogicalScale(4.0, 2.0);
m_dc->SetLogicalOrigin(-15, -20);
m_dc->SetClippingRegion(-10, -20, 80, 75);
m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID));
m_dc->Clear();
CheckBox(-10, -20, 40, 35);
}
void ClippingBoxTestCaseBase::TwoRegionsOverlapping() void ClippingBoxTestCaseBase::TwoRegionsOverlapping()
{ {
// Setting one clipping box and next another box (partially overlapping). // Setting one clipping box and next another box (partially overlapping).

View File

@@ -633,7 +633,7 @@ bool TestApp::OnInit()
Connect(wxEVT_IDLE, wxIdleEventHandler(TestApp::OnIdle)); Connect(wxEVT_IDLE, wxIdleEventHandler(TestApp::OnIdle));
#ifdef __WXGTK__ #ifdef __WXGTK20__
g_log_set_default_handler(wxTestGLogHandler, NULL); g_log_set_default_handler(wxTestGLogHandler, NULL);
#endif // __WXGTK__ #endif // __WXGTK__