mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-10-07 14:54:00 +08:00
recreating Xcode project files with new script
This commit is contained in:
+6225
-6207
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -380,6 +380,7 @@ public:
|
||||
typedef void (*wxOSX_TextEventHandlerPtr)(NSView* self, SEL _cmd, NSString *event);
|
||||
typedef void (*wxOSX_EventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
|
||||
typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
|
||||
typedef void (*wxOSX_DoCommandBySelectorPtr)(NSView* self, SEL _cmd, SEL _sel);
|
||||
typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
|
||||
typedef void (*wxOSX_DoCommandBySelectorPtr)(NSView* self, SEL _cmd, SEL _sel);
|
||||
typedef NSDragOperation (*wxOSX_DraggingEnteredOrUpdatedHandlerPtr)(NSView *self, SEL _cmd, void *sender);
|
||||
|
||||
@@ -36,6 +36,81 @@
|
||||
#include "canvas.h"
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// implementations
|
||||
// ============================================================================
|
||||
|
||||
class ImageRGBMatcher
|
||||
{
|
||||
public:
|
||||
ImageRGBMatcher(const wxImage& image, int tolerance)
|
||||
: m_image(image)
|
||||
, m_tolerance(tolerance)
|
||||
{
|
||||
}
|
||||
|
||||
bool match(const wxImage& other)
|
||||
{
|
||||
if ( other.GetWidth() != m_image.GetWidth() )
|
||||
return false;
|
||||
|
||||
if ( other.GetHeight() != m_image.GetHeight() )
|
||||
return false;
|
||||
|
||||
if ( memcmp(other.GetData(), m_image.GetData(),
|
||||
other.GetWidth()*other.GetHeight()*3) == 0 )
|
||||
return true;
|
||||
|
||||
const unsigned char* d1 = m_image.GetData();
|
||||
const unsigned char* d2 = other.GetData();
|
||||
for ( int x = 0; x < m_image.GetWidth(); ++x )
|
||||
{
|
||||
for ( int y = 0; y < m_image.GetHeight(); ++y )
|
||||
{
|
||||
const unsigned char diff = *d1 > * d2 ? *d1 - *d2 : *d2 - *d1;
|
||||
if (diff > m_tolerance)
|
||||
{
|
||||
m_diffDesc.Printf
|
||||
(
|
||||
"first mismatch is at (%d, %d) which "
|
||||
"has value 0x%06x instead of the "
|
||||
"expected 0x%06x",
|
||||
x, y, *d2, *d1
|
||||
);
|
||||
|
||||
// Don't show all mismatches, there may be too many of them.
|
||||
return false;
|
||||
}
|
||||
|
||||
++d1;
|
||||
++d2;
|
||||
}
|
||||
}
|
||||
|
||||
// We can only get here when the images are different AND we've not exited the
|
||||
// method from the loop. That implies the tolerance must have caused this.
|
||||
wxASSERT_MSG(m_tolerance > 0, "Unreachable without tolerance");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
const wxImage m_image;
|
||||
const int m_tolerance;
|
||||
mutable wxString m_diffDesc;
|
||||
};
|
||||
|
||||
inline ImageRGBMatcher RGBSameAs(const wxImage& image)
|
||||
{
|
||||
return ImageRGBMatcher(image, 0);
|
||||
}
|
||||
|
||||
// Allows small differences (within given tolerance) for r, g, and b values.
|
||||
inline ImageRGBMatcher RGBSimilarTo(const wxImage& image, int tolerance)
|
||||
{
|
||||
return ImageRGBMatcher(image, tolerance);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyCanvas
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -106,6 +181,16 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
else
|
||||
{
|
||||
my_toucan = wxBitmap(image);
|
||||
bool result = false;
|
||||
{
|
||||
if( my_toucan.IsOk() )
|
||||
{
|
||||
auto match = RGBSimilarTo( my_toucan.ConvertToImage() , 2 );
|
||||
result = match.match(image);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
my_toucan_flipped_horiz = wxBitmap(image.Mirror(true));
|
||||
|
||||
@@ -1012,10 +1012,6 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementations
|
||||
// ============================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyImageFrame
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1157,6 +1153,7 @@ MyFrame::MyFrame()
|
||||
// 500 width * 2750 height
|
||||
m_canvas->SetScrollbars( 10, 10, 50, 275 );
|
||||
m_canvas->SetCursor(wxImage("cursor.png"));
|
||||
|
||||
}
|
||||
|
||||
void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
|
||||
|
||||
Regular → Executable
+16
@@ -63,6 +63,8 @@ public:
|
||||
// event handlers (these functions should _not_ be virtual)
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnClick(wxMouseEvent& event);
|
||||
|
||||
private:
|
||||
// any class wishing to process wxWidgets events must use this macro
|
||||
@@ -95,6 +97,8 @@ enum
|
||||
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||
EVT_PAINT( MyFrame::OnPaint)
|
||||
EVT_LEFT_DOWN( MyFrame::OnClick)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
// Create a new application object: this macro will allow wxWidgets to create
|
||||
@@ -177,6 +181,18 @@ MyFrame::MyFrame(const wxString& title)
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
void MyFrame::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
wxRect update = GetUpdateRegion().GetBox();
|
||||
printf("update %d,%d,%d,%d\n",update.GetX(), update.GetY(), update.GetWidth(), update.GetHeight());
|
||||
}
|
||||
|
||||
void MyFrame::OnClick(wxMouseEvent& event)
|
||||
{
|
||||
wxRect r( event.GetX(), event.GetY(),2,2);
|
||||
RefreshRect(r);
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user