split EvasCanvas and EvasImage to separate files

SVN revision: 38401
This commit is contained in:
Andreas Volz 2009-01-01 13:56:39 +00:00
parent 2ab73e9cdf
commit e74f5e323c
12 changed files with 483 additions and 412 deletions

View File

@ -3,6 +3,7 @@
#endif
#include "eflpp_ecore_window.h"
#include <eflpp_evascanvas.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>

View File

@ -10,6 +10,7 @@
#include <eflpp_evasutils.h>
#include <eflpp_common.h>
#include <eflpp_countedptr.h>
#include <eflpp_evascanvas.h>
/* EFL */
#include <Edje.h>

View File

@ -8,6 +8,8 @@
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_evascanvas.h>
#include <eflpp_evasobject.h>
/* STD */
#include <iostream>

View File

@ -8,6 +8,7 @@
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_evascanvas.h>
/**
* C++ Wrapper for the Enlightenment Smart Object Library (ESMART)

View File

@ -8,6 +8,7 @@
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_countedptr.h>
#include <eflpp_evascanvas.h>
#include "eflpp_etkcontainer.h"
#include "eflpp_etkimage.h"

View File

@ -11,7 +11,9 @@ libeflpp_evas_la_SOURCES = \
eflpp_evas.cpp\
eflpp_evasfont.cpp\
eflpp_evastextblockstyle.cpp\
eflpp_evasobject.cpp
eflpp_evasobject.cpp\
eflpp_evascanvas.cpp\
eflpp_evasimage.cpp
libeflpp_includedir = $(pkgincludedir)
@ -21,6 +23,8 @@ libeflpp_include_DATA = \
eflpp_evastextblockstyle.h\
eflpp_evas.h\
eflpp_evasutils.h\
eflpp_evasobject.h
eflpp_evasobject.h\
eflpp_evascanvas.h\
eflpp_evasimage.h
EXTRA_DIST = $(libeflpp_include_DATA)

View File

@ -4,6 +4,7 @@
#include <eflpp_sys.h>
#include <eflpp_common.h>
#include <eflpp_evasimage.h>
#include "eflpp_evas.h"
#include "eflpp_evastextblockstyle.h"
@ -32,164 +33,6 @@ namespace efl {
char* EvasImage::_resourcePath = 0;
//===============================================================================================
// Canvas
//===============================================================================================
EvasCanvas::EvasCanvas()
:Trackable( "EvasCanvas" )
{
AllocTag( this, "EvasCanvas" );
Dout( dc::notice, "EvasCanvas::EvasCanvas - creating new Evas" );
o = evas_new();
}
EvasCanvas::EvasCanvas( Evas* evas )
:Trackable( "EvasCanvas" )
{
AllocTag( this, "EvasCanvas" );
Dout( dc::notice, "EvasCanvas::EvasCanvas - attaching to Evas" );
o = evas;
}
EvasCanvas::EvasCanvas( int width, int height )
:Trackable( "EvasCanvas" )
{
AllocTag( this, "EvasCanvas" );
Dout( dc::notice, "EvasCanvas::EvasCanvas - creating new Evas" );
o = evas_new();
resize( width, height );
setViewport( 0, 0, width, height );
}
EvasCanvas::~EvasCanvas()
{
Dout( dc::notice, "EvasCanvas::~Canvas - freeing Evas" );
evas_free( o );
}
int EvasCanvas::lookupRenderMethod( const char* method )
{
return evas_render_method_lookup( method );
}
bool EvasCanvas::setOutputMethod( const char* method )
{
int id = lookupRenderMethod( method );
if ( id )
{
evas_output_method_set( o, id );
return true;
}
return false;
}
void EvasCanvas::resize( int width, int height )
{
evas_output_size_set( o, width, height );
}
Size EvasCanvas::size() const
{
int width;
int height;
evas_output_size_get( o, &width, &height );
return Size( width, height );
}
Rect EvasCanvas::geometry() const
{
int width;
int height;
evas_output_size_get( o, &width, &height );
return Rect( 0, 0, width, height );
}
void EvasCanvas::setViewport( int x, int y, int width, int height )
{
evas_output_viewport_set( o, x, y, width, height );
}
Rect EvasCanvas::viewport() const
{
int x;
int y;
int width;
int height;
evas_output_viewport_get( o, &x, &y, &width, &height );
return Rect( x, y, width, height );
}
void EvasCanvas::appendFontPath( const char* path )
{
evas_font_path_append( o, path );
}
void EvasCanvas::clearFontPath()
{
evas_font_path_clear( o );
}
const Evas_List* EvasCanvas::fontPath()
{
return evas_font_path_list( o );
}
void EvasCanvas::prependFontPath( const char* path )
{
evas_font_path_prepend( o, path );
}
int EvasCanvas::fontCache()
{
return evas_font_cache_get( o );
}
void EvasCanvas::flushFontCache()
{
evas_font_cache_flush( o );
}
void EvasCanvas::setFontCache( unsigned int size )
{
evas_font_cache_set( o, size );
}
int EvasCanvas::imageCache()
{
return evas_image_cache_get( o );
}
void EvasCanvas::flushImageCache()
{
evas_image_cache_flush( o );
}
void EvasCanvas::reloadImageCache()
{
evas_image_cache_reload( o );
}
void EvasCanvas::setImageCache( unsigned int size )
{
evas_image_cache_set( o, size );
}
EvasObject* EvasCanvas::focusedObject() const
{
return EvasObject::objectLink( evas_focus_get( o ) );
}
EvasObject* EvasCanvas::objectAtTop() const
{
return EvasObject::objectLink( evas_object_top_get( o ) );
}
EvasObject* EvasCanvas::objectAtBottom() const
{
return EvasObject::objectLink( evas_object_bottom_get( o ) );
}
//===============================================================================================
// Line
//===============================================================================================
@ -453,146 +296,6 @@ EvasTextblock::~EvasTextblock()
evas_object_del( o );
}
//===============================================================================================
// Image
//===============================================================================================
EvasImage::EvasImage( EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : "image" );
_size = size ();
resize( _size );
}
EvasImage::EvasImage( const char* filename, EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : filename );
setFile( filename );
_size = size();
resize( _size );
}
EvasImage::EvasImage( int x, int y, const char* filename, EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : filename );
setFile( filename );
move( x, y );
_size = size();
resize( _size );
}
// attach temporary disabled
#if 0
EvasImage::EvasImage( Evas_Object* object, EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : type );
o = object;
_size = size();
}
#endif
EvasImage::~EvasImage()
{
evas_object_del( o );
}
bool EvasImage::setFile( const char* path, const char* key )
{
const char* p = path;
const char* k = key;
if ( ( EvasImage::_resourcePath ) && ( path[0] != '/' ) )
{
p = EvasImage::_resourcePath;
k = path;
}
evas_object_image_file_set( o, p, k );
int errorcode = evas_object_image_load_error_get(o);
Dout( dc::notice, *this << " EvasImage::file_set" << " path=" << p << ( k ? k : "<none>" )
<< "(" << EVAS_LOAD_ERROR[errorcode] << ")" );
if ( errorcode ) cerr << "ERROR: EvasImage::setFile( '" << p << "|" << ( k ? k : "<none>" ) << ") = " << EVAS_LOAD_ERROR[errorcode] << endl;
return ( errorcode == 0 );
}
void EvasImage::setFill( int x, int y, int width, int height )
{
Dout( dc::notice, *this << " EvasImage::fill_set" << " x=" << x << " y=" << y << " width=" << width << " height=" << height );
evas_object_image_fill_set( o, x, y, width, height );
}
void EvasImage::setFill( int x, int y, const Size& size )
{
setFill( x, y, size.width(), size.height() );
}
void EvasImage::resize( int width, int height, bool ff )
{
EvasObject::resize( width, height );
if ( ff ) setFill( 0, 0, width, height );
}
void EvasImage::resize( const Size& size, bool ff )
{
Dout( dc::notice, *this << " EvasImage::resize current size is " << size.width() << ", " << size.height() );
resize( size.width(), size.height(), ff );
}
const Size EvasImage::size() const
{
int w, h;
evas_object_image_size_get( o, &w, &h );
return Size( w, h );
}
const Size& EvasImage::trueSize()
{
return _size;
}
void EvasImage::setImageSize (int w, int h)
{
evas_object_image_size_set (o, w, h);
}
void EvasImage::getImageSize (int &w, int &h)
{
evas_object_image_size_get (o, &w, &h);
}
void EvasImage::setBorder( int left, int right, int top, int bottom )
{
evas_object_image_border_set( o, left, right, top, bottom );
}
void EvasImage::setData (void *data)
{
evas_object_image_data_set (o, data);
}
void *EvasImage::getData (bool for_writing)
{
return evas_object_image_data_get (o, for_writing);
}
void EvasImage::setDataCopy (void *data)
{
evas_object_image_data_copy_set (o, data);
}
void EvasImage::addDataUpdate (int x, int y, int w, int h)
{
evas_object_image_data_update_add (o, x, y, w, h);
}
//===============================================================================================
// Gradient
//===============================================================================================

View File

@ -5,6 +5,8 @@
#include "eflpp_evasfont.h"
#include "eflpp_evasutils.h"
#include "eflpp_evasobject.h"
#include "eflpp_evascanvas.h"
#include "eflpp_evasimage.h"
/* EFL++ */
#include <eflpp_common.h>
@ -42,60 +44,6 @@ class EvasRectangle;
class EvasText;
class EvasTextblockStyle;
/**
* An Evas Canvas Wrapper
*/
class EvasCanvas : public Trackable
{
public:
EvasCanvas( int width, int height );
EvasCanvas( Evas* evas );
EvasCanvas();
~EvasCanvas();
Evas* obj() const { return o; };
/* Output Methods */
int lookupRenderMethod( const char* method );
/*! \brief Set the Evas output method.
* This does include a call to lookupRenderMethod().
* @param method Name of the output method. (See C API docs).
*/
bool setOutputMethod( const char* method );
void resize( int width, int height );
Size size() const;
Rect geometry() const;
void setViewport( int x, int y, int width, int height );
Rect viewport() const;
/* Font Path */
void appendFontPath( const char* path );
void prependFontPath( const char* path );
void clearFontPath();
const Evas_List* fontPath();
/* Font Cache */
void setFontCache( unsigned int size );
void flushFontCache();
int fontCache();
/* Image Cache */
void setImageCache( unsigned int size );
void flushImageCache();
void reloadImageCache();
int imageCache();
/* Object queries */
EvasObject* focusedObject() const;
EvasObject* objectAtTop() const;
EvasObject* objectAtBottom() const;
protected:
Evas* o;
};
/**
* Wraps an Evas Line Object
*/
@ -188,64 +136,6 @@ class EvasTextblock : public EvasObject
void clear();
};
/*
* Wraps an Evas Image Object
*/
class EvasImage : public EvasObject
{
public:
EvasImage( EvasCanvas* canvas, const char* name = 0 );
EvasImage( const char* filename, EvasCanvas* canvas, const char* name = 0 );
EvasImage( int x, int y, const char* filename, EvasCanvas* canvas, const char* name = 0 );
EvasImage( Evas_Object* object, EvasCanvas* canvas, const char* name = 0 );
virtual ~EvasImage();
/**
* Sets the @filename containing the image data.
* If the image data resides in an .eet or .edb you probably
* want to supply a @key specifying the image name.
* @returns true, if the image could be loaded, false, otherwise.
* @see evas_object_image_file_set
*/
bool setFile( const char* path, const char* key = 0 );
void setFill( int x, int y, int width, int height );
void setFill( int x, int y, const Size& );
/* Size */
virtual void resize( int width, int height, bool ff = true );
virtual void resize( const Size& size, bool ff = true );
virtual const Size size() const;
const Size& trueSize();
/// Sets the size of the image to be display by the given image object.
void setImageSize (int w, int h);
/// Retrieves the size of the image displayed by the given image object.
void getImageSize (int &w, int &h);
/* Border */
void setBorder( int left, int right, int top, int bottom );
/// Sets the raw image data.
void setData (void *data);
/// Retrieves the raw image data.
void *getData (bool for_writing);
/// Replaces an image object's internal image data buffer.
void setDataCopy (void *data);
/// Update a rectangle after putting data into the image.
void addDataUpdate (int x, int y, int w, int h);
static void setResourcePath( const char* path ) { EvasImage::_resourcePath = (char*) path; };
static const char* resourcePath() { return EvasImage::_resourcePath; };
private:
static char* _resourcePath;
Size _size; // true size
};
/*
* Wraps an Evas Gradient Object
*/

View File

@ -0,0 +1,165 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "eflpp_evascanvas.h"
using namespace std;
namespace efl {
EvasCanvas::EvasCanvas()
:Trackable( "EvasCanvas" )
{
AllocTag( this, "EvasCanvas" );
Dout( dc::notice, "EvasCanvas::EvasCanvas - creating new Evas" );
o = evas_new();
}
EvasCanvas::EvasCanvas( Evas* evas )
:Trackable( "EvasCanvas" )
{
AllocTag( this, "EvasCanvas" );
Dout( dc::notice, "EvasCanvas::EvasCanvas - attaching to Evas" );
o = evas;
}
EvasCanvas::EvasCanvas( int width, int height )
:Trackable( "EvasCanvas" )
{
AllocTag( this, "EvasCanvas" );
Dout( dc::notice, "EvasCanvas::EvasCanvas - creating new Evas" );
o = evas_new();
resize( width, height );
setViewport( 0, 0, width, height );
}
EvasCanvas::~EvasCanvas()
{
Dout( dc::notice, "EvasCanvas::~Canvas - freeing Evas" );
evas_free( o );
}
int EvasCanvas::lookupRenderMethod( const char* method )
{
return evas_render_method_lookup( method );
}
bool EvasCanvas::setOutputMethod( const char* method )
{
int id = lookupRenderMethod( method );
if ( id )
{
evas_output_method_set( o, id );
return true;
}
return false;
}
void EvasCanvas::resize( int width, int height )
{
evas_output_size_set( o, width, height );
}
Size EvasCanvas::size() const
{
int width;
int height;
evas_output_size_get( o, &width, &height );
return Size( width, height );
}
Rect EvasCanvas::geometry() const
{
int width;
int height;
evas_output_size_get( o, &width, &height );
return Rect( 0, 0, width, height );
}
void EvasCanvas::setViewport( int x, int y, int width, int height )
{
evas_output_viewport_set( o, x, y, width, height );
}
Rect EvasCanvas::viewport() const
{
int x;
int y;
int width;
int height;
evas_output_viewport_get( o, &x, &y, &width, &height );
return Rect( x, y, width, height );
}
void EvasCanvas::appendFontPath( const char* path )
{
evas_font_path_append( o, path );
}
void EvasCanvas::clearFontPath()
{
evas_font_path_clear( o );
}
const Evas_List* EvasCanvas::fontPath()
{
return evas_font_path_list( o );
}
void EvasCanvas::prependFontPath( const char* path )
{
evas_font_path_prepend( o, path );
}
int EvasCanvas::fontCache()
{
return evas_font_cache_get( o );
}
void EvasCanvas::flushFontCache()
{
evas_font_cache_flush( o );
}
void EvasCanvas::setFontCache( unsigned int size )
{
evas_font_cache_set( o, size );
}
int EvasCanvas::imageCache()
{
return evas_image_cache_get( o );
}
void EvasCanvas::flushImageCache()
{
evas_image_cache_flush( o );
}
void EvasCanvas::reloadImageCache()
{
evas_image_cache_reload( o );
}
void EvasCanvas::setImageCache( unsigned int size )
{
evas_image_cache_set( o, size );
}
EvasObject* EvasCanvas::focusedObject() const
{
return EvasObject::objectLink( evas_focus_get( o ) );
}
EvasObject* EvasCanvas::objectAtTop() const
{
return EvasObject::objectLink( evas_object_top_get( o ) );
}
EvasObject* EvasCanvas::objectAtBottom() const
{
return EvasObject::objectLink( evas_object_bottom_get( o ) );
}
} // end namespace efl

View File

@ -0,0 +1,75 @@
#ifndef EFLPP_EVASCANVAS_H
#define EFLPP_EVASCANVAS_H
/* STL */
#include <string>
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_countedptr.h>
#include "eflpp_evasobject.h"
/* EFL */
#include <Evas.h>
using std::string;
namespace efl {
/**
* An Evas Canvas Wrapper
*/
class EvasCanvas : public Trackable
{
public:
EvasCanvas( int width, int height );
EvasCanvas( Evas* evas );
EvasCanvas();
~EvasCanvas();
Evas* obj() const { return o; };
/* Output Methods */
int lookupRenderMethod( const char* method );
/** @brief Set the Evas output method.
* This does include a call to lookupRenderMethod().
* @param method Name of the output method. (See C API docs).
*/
bool setOutputMethod( const char* method );
void resize( int width, int height );
Size size() const;
Rect geometry() const;
void setViewport( int x, int y, int width, int height );
Rect viewport() const;
/* Font Path */
void appendFontPath( const char* path );
void prependFontPath( const char* path );
void clearFontPath();
const Evas_List* fontPath();
/* Font Cache */
void setFontCache( unsigned int size );
void flushFontCache();
int fontCache();
/* Image Cache */
void setImageCache( unsigned int size );
void flushImageCache();
void reloadImageCache();
int imageCache();
/* Object queries */
EvasObject* focusedObject() const;
EvasObject* objectAtTop() const;
EvasObject* objectAtBottom() const;
protected:
Evas* o;
};
} // end namespace efl
#endif // EFLPP_EVASCANVAS_H

View File

@ -0,0 +1,148 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "eflpp_evasimage.h"
using namespace std;
namespace efl {
EvasImage::EvasImage( EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : "image" );
_size = size ();
resize( _size );
}
EvasImage::EvasImage( const char* filename, EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : filename );
setFile( filename );
_size = size();
resize( _size );
}
EvasImage::EvasImage( int x, int y, const char* filename, EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : filename );
setFile( filename );
move( x, y );
_size = size();
resize( _size );
}
// attach temporary disabled
#if 0
EvasImage::EvasImage( Evas_Object* object, EvasCanvas* canvas, const char* name )
{
o = evas_object_image_add( canvas->obj() );
init( name ? name : type );
o = object;
_size = size();
}
#endif
EvasImage::~EvasImage()
{
evas_object_del( o );
}
bool EvasImage::setFile( const char* path, const char* key )
{
const char* p = path;
const char* k = key;
if ( ( EvasImage::_resourcePath ) && ( path[0] != '/' ) )
{
p = EvasImage::_resourcePath;
k = path;
}
evas_object_image_file_set( o, p, k );
int errorcode = evas_object_image_load_error_get(o);
// TODO: commented out because of file split. Find a better way! Maybe Exceptions?
/* Dout( dc::notice, *this << " EvasImage::file_set" << " path=" << p << ( k ? k : "<none>" )
<< "(" << EVAS_LOAD_ERROR[errorcode] << ")" );
if ( errorcode ) cerr << "ERROR: EvasImage::setFile( '" << p << "|" << ( k ? k : "<none>" ) << ") = " << EVAS_LOAD_ERROR[errorcode] << endl;
*/ return ( errorcode == 0 );
}
void EvasImage::setFill( int x, int y, int width, int height )
{
Dout( dc::notice, *this << " EvasImage::fill_set" << " x=" << x << " y=" << y << " width=" << width << " height=" << height );
evas_object_image_fill_set( o, x, y, width, height );
}
void EvasImage::setFill( int x, int y, const Size& size )
{
setFill( x, y, size.width(), size.height() );
}
void EvasImage::resize( int width, int height, bool ff )
{
EvasObject::resize( width, height );
if ( ff ) setFill( 0, 0, width, height );
}
void EvasImage::resize( const Size& size, bool ff )
{
Dout( dc::notice, *this << " EvasImage::resize current size is " << size.width() << ", " << size.height() );
resize( size.width(), size.height(), ff );
}
const Size EvasImage::size() const
{
int w, h;
evas_object_image_size_get( o, &w, &h );
return Size( w, h );
}
const Size& EvasImage::trueSize()
{
return _size;
}
void EvasImage::setImageSize (int w, int h)
{
evas_object_image_size_set (o, w, h);
}
void EvasImage::getImageSize (int &w, int &h)
{
evas_object_image_size_get (o, &w, &h);
}
void EvasImage::setBorder( int left, int right, int top, int bottom )
{
evas_object_image_border_set( o, left, right, top, bottom );
}
void EvasImage::setData (void *data)
{
evas_object_image_data_set (o, data);
}
void *EvasImage::getData (bool for_writing)
{
return evas_object_image_data_get (o, for_writing);
}
void EvasImage::setDataCopy (void *data)
{
evas_object_image_data_copy_set (o, data);
}
void EvasImage::addDataUpdate (int x, int y, int w, int h)
{
evas_object_image_data_update_add (o, x, y, w, h);
}
} // end namespace efl

View File

@ -0,0 +1,80 @@
#ifndef EFLPP_EVASIMAGE_H
#define EFLPP_EVASIMAGE_H
/* STL */
#include <string>
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_countedptr.h>
#include "eflpp_evasobject.h"
#include "eflpp_evascanvas.h"
/* EFL */
#include <Evas.h>
using std::string;
namespace efl {
/**
* Wraps an Evas Image Object
*/
class EvasImage : public EvasObject
{
public:
EvasImage( EvasCanvas* canvas, const char* name = 0 );
EvasImage( const char* filename, EvasCanvas* canvas, const char* name = 0 );
EvasImage( int x, int y, const char* filename, EvasCanvas* canvas, const char* name = 0 );
EvasImage( Evas_Object* object, EvasCanvas* canvas, const char* name = 0 );
virtual ~EvasImage();
/**
* Sets the @filename containing the image data.
* If the image data resides in an .eet or .edb you probably
* want to supply a @key specifying the image name.
* @returns true, if the image could be loaded, false, otherwise.
* @see evas_object_image_file_set
*/
bool setFile( const char* path, const char* key = 0 );
void setFill( int x, int y, int width, int height );
void setFill( int x, int y, const Size& );
/* Size */
virtual void resize( int width, int height, bool ff = true );
virtual void resize( const Size& size, bool ff = true );
virtual const Size size() const;
const Size& trueSize();
/// Sets the size of the image to be display by the given image object.
void setImageSize (int w, int h);
/// Retrieves the size of the image displayed by the given image object.
void getImageSize (int &w, int &h);
/* Border */
void setBorder( int left, int right, int top, int bottom );
/// Sets the raw image data.
void setData (void *data);
/// Retrieves the raw image data.
void *getData (bool for_writing);
/// Replaces an image object's internal image data buffer.
void setDataCopy (void *data);
/// Update a rectangle after putting data into the image.
void addDataUpdate (int x, int y, int w, int h);
static void setResourcePath( const char* path ) { EvasImage::_resourcePath = (char*) path; };
static const char* resourcePath() { return EvasImage::_resourcePath; };
private:
static char* _resourcePath;
Size _size; // true size
};
} // end namespoace efl
#endif // EFLPP_EVASIMAGE_H