Minor update to wxCanvas.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e83bf4f7e1
commit
1e1af41e4b
@ -33,10 +33,18 @@ class wxCanvasObject: public wxEvtHandler
|
|||||||
public:
|
public:
|
||||||
wxCanvasObject( int x, int y, int width, int height );
|
wxCanvasObject( int x, int y, int width, int height );
|
||||||
|
|
||||||
|
// These are for screen output only therefore use
|
||||||
|
// int as coordinates.
|
||||||
virtual void Move( int x, int y );
|
virtual void Move( int x, int y );
|
||||||
virtual bool IsHit( int x, int y, int margin = 0 );
|
virtual bool IsHit( int x, int y, int margin = 0 );
|
||||||
|
|
||||||
virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
|
virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
|
||||||
|
|
||||||
|
// Once we have world coordinates in doubles, this will get
|
||||||
|
// called for every object if the world coordinate system
|
||||||
|
// changes (zooming).
|
||||||
|
virtual void Rerender();
|
||||||
|
|
||||||
|
// Later...
|
||||||
virtual void WriteSVG( wxTextOutputStream &stream );
|
virtual void WriteSVG( wxTextOutputStream &stream );
|
||||||
|
|
||||||
wxCanvas *GetOwner() { return m_owner; }
|
wxCanvas *GetOwner() { return m_owner; }
|
||||||
@ -188,6 +196,7 @@ public:
|
|||||||
|
|
||||||
wxImage *GetBuffer() { return &m_buffer; }
|
wxImage *GetBuffer() { return &m_buffer; }
|
||||||
bool NeedUpdate() { return m_needUpdate; }
|
bool NeedUpdate() { return m_needUpdate; }
|
||||||
|
bool IsFrozen() { return m_frozen; }
|
||||||
|
|
||||||
void BlitBuffer( wxDC &dc );
|
void BlitBuffer( wxDC &dc );
|
||||||
|
|
||||||
@ -200,7 +209,6 @@ private:
|
|||||||
bool m_frozen;
|
bool m_frozen;
|
||||||
wxCanvasObject *m_lastMouse;
|
wxCanvasObject *m_lastMouse;
|
||||||
|
|
||||||
|
|
||||||
friend class wxCanvasObject;
|
friend class wxCanvasObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -25,17 +25,19 @@
|
|||||||
#include "wx/gtk/win_gtk.h"
|
#include "wx/gtk/win_gtk.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USE_FREETYPE 1
|
#ifndef wxUSE_FREETYPE
|
||||||
|
#define wxUSE_FREETYPE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
#include <freetype/freetype.h>
|
#include <freetype/freetype.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// globals
|
// globals
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
FT_Library g_freetypeLibrary;
|
FT_Library g_freetypeLibrary;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -80,11 +82,15 @@ bool wxCanvasObject::IsHit( int x, int y, int margin )
|
|||||||
(y <= m_area.y+m_area.height+margin));
|
(y <= m_area.y+m_area.height+margin));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCanvasObject::WriteSVG( wxTextOutputStream &stream )
|
void wxCanvasObject::Render( int clip_x, int clip_y, int clip_width, int clip_height )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCanvasObject::Render( int clip_x, int clip_y, int clip_width, int clip_height )
|
void wxCanvasObject::Rerender()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCanvasObject::WriteSVG( wxTextOutputStream &stream )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +204,7 @@ void wxCanvasLine::Render( int clip_x, int clip_y, int clip_width, int clip_heig
|
|||||||
|
|
||||||
void wxCanvasLine::WriteSVG( wxTextOutputStream &stream )
|
void wxCanvasLine::WriteSVG( wxTextOutputStream &stream )
|
||||||
{
|
{
|
||||||
|
// no idea
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -272,7 +279,7 @@ void wxCanvasControl::UpdateSize()
|
|||||||
class wxFaceData
|
class wxFaceData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
FT_Face m_face;
|
FT_Face m_face;
|
||||||
#else
|
#else
|
||||||
void *m_dummy;
|
void *m_dummy;
|
||||||
@ -296,7 +303,7 @@ wxCanvasText::wxCanvasText( const wxString &text, int x, int y, const wxString &
|
|||||||
m_alpha = new unsigned char[100*m_size];
|
m_alpha = new unsigned char[100*m_size];
|
||||||
memset( m_alpha, 0, m_area.width*m_area.height );
|
memset( m_alpha, 0, m_area.width*m_area.height );
|
||||||
|
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
wxFaceData *data = new wxFaceData;
|
wxFaceData *data = new wxFaceData;
|
||||||
m_faceData = data;
|
m_faceData = data;
|
||||||
|
|
||||||
@ -316,7 +323,7 @@ wxCanvasText::wxCanvasText( const wxString &text, int x, int y, const wxString &
|
|||||||
|
|
||||||
wxCanvasText::~wxCanvasText()
|
wxCanvasText::~wxCanvasText()
|
||||||
{
|
{
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
wxFaceData *data = (wxFaceData*) m_faceData;
|
wxFaceData *data = (wxFaceData*) m_faceData;
|
||||||
delete data;
|
delete data;
|
||||||
#endif
|
#endif
|
||||||
@ -384,7 +391,7 @@ void wxCanvasText::WriteSVG( wxTextOutputStream &stream )
|
|||||||
|
|
||||||
void wxCanvasText::CreateBuffer()
|
void wxCanvasText::CreateBuffer()
|
||||||
{
|
{
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
FT_Face face = ((wxFaceData*)m_faceData)->m_face;
|
FT_Face face = ((wxFaceData*)m_faceData)->m_face;
|
||||||
FT_GlyphSlot slot = face->glyph;
|
FT_GlyphSlot slot = face->glyph;
|
||||||
int pen_x = 0;
|
int pen_x = 0;
|
||||||
@ -761,8 +768,8 @@ void wxCanvas::OnMouse(wxMouseEvent &event)
|
|||||||
{
|
{
|
||||||
wxMouseEvent child_event( wxEVT_MOTION );
|
wxMouseEvent child_event( wxEVT_MOTION );
|
||||||
child_event.SetEventObject( obj );
|
child_event.SetEventObject( obj );
|
||||||
child_event.m_x = x + obj->GetX();
|
child_event.m_x = x - obj->GetX();
|
||||||
child_event.m_y = y + obj->GetY();
|
child_event.m_y = y - obj->GetY();
|
||||||
child_event.m_leftDown = event.m_leftDown;
|
child_event.m_leftDown = event.m_leftDown;
|
||||||
child_event.m_rightDown = event.m_rightDown;
|
child_event.m_rightDown = event.m_rightDown;
|
||||||
child_event.m_middleDown = event.m_middleDown;
|
child_event.m_middleDown = event.m_middleDown;
|
||||||
@ -775,15 +782,15 @@ void wxCanvas::OnMouse(wxMouseEvent &event)
|
|||||||
{
|
{
|
||||||
child_event.SetEventType( wxEVT_LEAVE_WINDOW );
|
child_event.SetEventType( wxEVT_LEAVE_WINDOW );
|
||||||
child_event.SetEventObject( m_lastMouse );
|
child_event.SetEventObject( m_lastMouse );
|
||||||
child_event.m_x = x + m_lastMouse->GetX();
|
child_event.m_x = x - m_lastMouse->GetX();
|
||||||
child_event.m_y = y + m_lastMouse->GetY();
|
child_event.m_y = y - m_lastMouse->GetY();
|
||||||
m_lastMouse->ProcessEvent( child_event );
|
m_lastMouse->ProcessEvent( child_event );
|
||||||
|
|
||||||
m_lastMouse = obj;
|
m_lastMouse = obj;
|
||||||
child_event.SetEventType( wxEVT_ENTER_WINDOW );
|
child_event.SetEventType( wxEVT_ENTER_WINDOW );
|
||||||
child_event.SetEventObject( m_lastMouse );
|
child_event.SetEventObject( m_lastMouse );
|
||||||
child_event.m_x = x + m_lastMouse->GetX();
|
child_event.m_x = x - m_lastMouse->GetX();
|
||||||
child_event.m_y = y + m_lastMouse->GetY();
|
child_event.m_y = y - m_lastMouse->GetY();
|
||||||
m_lastMouse->ProcessEvent( child_event );
|
m_lastMouse->ProcessEvent( child_event );
|
||||||
|
|
||||||
child_event.SetEventType( wxEVT_MOTION );
|
child_event.SetEventType( wxEVT_MOTION );
|
||||||
@ -799,8 +806,8 @@ void wxCanvas::OnMouse(wxMouseEvent &event)
|
|||||||
{
|
{
|
||||||
wxMouseEvent child_event( wxEVT_LEAVE_WINDOW );
|
wxMouseEvent child_event( wxEVT_LEAVE_WINDOW );
|
||||||
child_event.SetEventObject( m_lastMouse );
|
child_event.SetEventObject( m_lastMouse );
|
||||||
child_event.m_x = x + m_lastMouse->GetX();
|
child_event.m_x = x - m_lastMouse->GetX();
|
||||||
child_event.m_y = y + m_lastMouse->GetY();
|
child_event.m_y = y - m_lastMouse->GetY();
|
||||||
child_event.m_leftDown = event.m_leftDown;
|
child_event.m_leftDown = event.m_leftDown;
|
||||||
child_event.m_rightDown = event.m_rightDown;
|
child_event.m_rightDown = event.m_rightDown;
|
||||||
child_event.m_middleDown = event.m_middleDown;
|
child_event.m_middleDown = event.m_middleDown;
|
||||||
@ -859,7 +866,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxCanvasModule, wxModule)
|
|||||||
|
|
||||||
bool wxCanvasModule::OnInit()
|
bool wxCanvasModule::OnInit()
|
||||||
{
|
{
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
int error = FT_Init_FreeType( &g_freetypeLibrary );
|
int error = FT_Init_FreeType( &g_freetypeLibrary );
|
||||||
if (error) return FALSE;
|
if (error) return FALSE;
|
||||||
#endif
|
#endif
|
||||||
@ -869,7 +876,7 @@ bool wxCanvasModule::OnInit()
|
|||||||
|
|
||||||
void wxCanvasModule::OnExit()
|
void wxCanvasModule::OnExit()
|
||||||
{
|
{
|
||||||
#if USE_FREETYPE
|
#if wxUSE_FREETYPE
|
||||||
FT_Done_FreeType( g_freetypeLibrary );
|
FT_Done_FreeType( g_freetypeLibrary );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user