From e74f5e323c201df5d6fc33ed6d3851f51aa23e56 Mon Sep 17 00:00:00 2001 From: Andreas Volz Date: Thu, 1 Jan 2009 13:56:39 +0000 Subject: [PATCH] split EvasCanvas and EvasImage to separate files SVN revision: 38401 --- src/ecore/eflpp_ecore_window.cpp | 1 + src/edje/eflpp_edje.h | 1 + src/emotion/eflpp_emotion.h | 2 + src/esmart/eflpp_esmart.h | 1 + src/etk/eflpp_etk.h | 1 + src/evas/Makefile.am | 8 +- src/evas/eflpp_evas.cpp | 299 +------------------------------ src/evas/eflpp_evas.h | 114 +----------- src/evas/eflpp_evascanvas.cpp | 165 +++++++++++++++++ src/evas/eflpp_evascanvas.h | 75 ++++++++ src/evas/eflpp_evasimage.cpp | 148 +++++++++++++++ src/evas/eflpp_evasimage.h | 80 +++++++++ 12 files changed, 483 insertions(+), 412 deletions(-) create mode 100644 src/evas/eflpp_evascanvas.cpp create mode 100644 src/evas/eflpp_evascanvas.h create mode 100644 src/evas/eflpp_evasimage.cpp create mode 100644 src/evas/eflpp_evasimage.h diff --git a/src/ecore/eflpp_ecore_window.cpp b/src/ecore/eflpp_ecore_window.cpp index 637c1df..db42861 100644 --- a/src/ecore/eflpp_ecore_window.cpp +++ b/src/ecore/eflpp_ecore_window.cpp @@ -3,6 +3,7 @@ #endif #include "eflpp_ecore_window.h" +#include #include #include #include diff --git a/src/edje/eflpp_edje.h b/src/edje/eflpp_edje.h index b2839f1..3dc302b 100644 --- a/src/edje/eflpp_edje.h +++ b/src/edje/eflpp_edje.h @@ -10,6 +10,7 @@ #include #include #include +#include /* EFL */ #include diff --git a/src/emotion/eflpp_emotion.h b/src/emotion/eflpp_emotion.h index ecfa015..931729e 100644 --- a/src/emotion/eflpp_emotion.h +++ b/src/emotion/eflpp_emotion.h @@ -8,6 +8,8 @@ /* EFL++ */ #include #include +#include +#include /* STD */ #include diff --git a/src/esmart/eflpp_esmart.h b/src/esmart/eflpp_esmart.h index a7ad013..022f0cc 100644 --- a/src/esmart/eflpp_esmart.h +++ b/src/esmart/eflpp_esmart.h @@ -8,6 +8,7 @@ /* EFL++ */ #include #include +#include /** * C++ Wrapper for the Enlightenment Smart Object Library (ESMART) diff --git a/src/etk/eflpp_etk.h b/src/etk/eflpp_etk.h index d792b16..7be76a9 100644 --- a/src/etk/eflpp_etk.h +++ b/src/etk/eflpp_etk.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "eflpp_etkcontainer.h" #include "eflpp_etkimage.h" diff --git a/src/evas/Makefile.am b/src/evas/Makefile.am index 9dec70b..c8fa806 100644 --- a/src/evas/Makefile.am +++ b/src/evas/Makefile.am @@ -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) diff --git a/src/evas/eflpp_evas.cpp b/src/evas/eflpp_evas.cpp index 956d418..b34d738 100644 --- a/src/evas/eflpp_evas.cpp +++ b/src/evas/eflpp_evas.cpp @@ -4,6 +4,7 @@ #include #include +#include #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 : "" ) - << "(" << EVAS_LOAD_ERROR[errorcode] << ")" ); - if ( errorcode ) cerr << "ERROR: EvasImage::setFile( '" << p << "|" << ( k ? k : "" ) << ") = " << 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 //=============================================================================================== diff --git a/src/evas/eflpp_evas.h b/src/evas/eflpp_evas.h index 4cdab4b..0232718 100644 --- a/src/evas/eflpp_evas.h +++ b/src/evas/eflpp_evas.h @@ -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 @@ -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 */ diff --git a/src/evas/eflpp_evascanvas.cpp b/src/evas/eflpp_evascanvas.cpp new file mode 100644 index 0000000..75dc392 --- /dev/null +++ b/src/evas/eflpp_evascanvas.cpp @@ -0,0 +1,165 @@ +#ifdef HAVE_CONFIG_H + #include +#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 diff --git a/src/evas/eflpp_evascanvas.h b/src/evas/eflpp_evascanvas.h new file mode 100644 index 0000000..b41e48e --- /dev/null +++ b/src/evas/eflpp_evascanvas.h @@ -0,0 +1,75 @@ +#ifndef EFLPP_EVASCANVAS_H +#define EFLPP_EVASCANVAS_H + +/* STL */ +#include + +/* EFL++ */ +#include +#include +#include "eflpp_evasobject.h" + +/* EFL */ +#include + +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 diff --git a/src/evas/eflpp_evasimage.cpp b/src/evas/eflpp_evasimage.cpp new file mode 100644 index 0000000..6a0d838 --- /dev/null +++ b/src/evas/eflpp_evasimage.cpp @@ -0,0 +1,148 @@ +#ifdef HAVE_CONFIG_H + #include +#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 : "" ) + << "(" << EVAS_LOAD_ERROR[errorcode] << ")" ); + if ( errorcode ) cerr << "ERROR: EvasImage::setFile( '" << p << "|" << ( k ? k : "" ) << ") = " << 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 diff --git a/src/evas/eflpp_evasimage.h b/src/evas/eflpp_evasimage.h new file mode 100644 index 0000000..bc26523 --- /dev/null +++ b/src/evas/eflpp_evasimage.h @@ -0,0 +1,80 @@ +#ifndef EFLPP_EVASIMAGE_H +#define EFLPP_EVASIMAGE_H + +/* STL */ +#include + +/* EFL++ */ +#include +#include +#include "eflpp_evasobject.h" +#include "eflpp_evascanvas.h" + +/* EFL */ +#include + +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