start to have one header and one cpp file for each class.

SVN revision: 38361
This commit is contained in:
Andreas Volz 2008-12-30 21:56:17 +00:00
parent a18c2d9c3e
commit aef9a46f42
14 changed files with 742 additions and 621 deletions

2
TODO
View File

@ -5,3 +5,5 @@
* split eflpp into seperate libs (e.g. eflpp-edje, eflpp-evas, ...)
* replace char* with string
* create a wrap() function for all classes
* use PImpl implementation to avoid include of EFL headers direct in applications
* one header and cpp file for each class

View File

@ -56,7 +56,7 @@ int main( int argc, const char **argv )
embed->show();
EtkButton* button = new EtkButton( "Hello World!" );
embed->appendChild( button );
embed->add( button );
button->show();
embed->show();

View File

@ -18,7 +18,7 @@ int main( int argc, const char **argv )
EtkButton* button = new EtkButton( "Hello World" );
button->setFromStock( ETK_STOCK_BOOKMARK_NEW );
button->setStockSize( ETK_STOCK_BIG );
mainWindow->appendChild( button );
mainWindow->add( button );
mainWindow->showAll();
cout << "calling main now" << endl;

View File

@ -9,11 +9,19 @@ AM_CXXFLAGS = @PACKAGE_CFLAGS@ \
noinst_LTLIBRARIES = libeflpp_etk.la
libeflpp_etk_la_SOURCES = \
eflpp_etk.cpp
eflpp_etk.cpp \
eflpp_etkimage.cpp \
eflpp_etkcontainer.cpp \
eflpp_etkwidget.cpp \
eflpp_etkobject.cpp
libeflpp_includedir = $(pkgincludedir)
libeflpp_include_DATA = \
eflpp_etk.h
eflpp_etk.h \
eflpp_etkimage.h \
eflpp_etkcontainer.h \
eflpp_etkwidget.h \
eflpp_etkobject.h
EXTRA_DIST = $(libeflpp_include_DATA)

View File

@ -14,161 +14,6 @@ namespace efl {
EtkApplication* EtkApplication::_instance = 0;
//==========================================================================//
// EwlObject
//==========================================================================//
EtkObject::EtkObject( EtkObject* parent, const char* type, const char* name )
:_o( 0 )
{
cout << "EtkObject::EtkObject - generating object '" << ( name ? name : "<unknown>" ) << "' (" << type << ")" << endl;
if ( strcmp( type, "TopLevelWidget" ) == 0 )
{
assert( not "implemented" );
//_o = ETK_OBJECT( etk_widget_new() );
}
else if ( strcmp( type, "Embed" ) == 0 )
{
// already created
}
else if ( strcmp( type, "Window" ) == 0 )
{
_o = ETK_OBJECT( etk_window_new() );
}
else if ( strcmp( type, "Button" ) == 0 )
{
_o = ETK_OBJECT( etk_button_new() );
}
else
assert( not "a known widget" );
}
EtkObject::~EtkObject()
{
}
void EtkObject::resize( const Size& size )
{
etk_widget_size_request_set( ETK_WIDGET(_o), size.width(), size.height() );
}
void EtkObject::setFillPolicy( )
{
}
void EtkObject::setAlignment( )
{
}
void EtkObject::init( )
{
_managed = true;
}
//==========================================================================//
// EtkWidget
//==========================================================================//
EtkWidget::EtkWidget( EtkObject* parent, const char* type, const char* name )
:EtkObject( parent, type, name )
{
init( );
}
EtkWidget::~EtkWidget()
{
}
void EtkWidget::show()
{
etk_widget_show( ETK_WIDGET(_o) );
}
void EtkWidget::showAll()
{
etk_widget_show_all( ETK_WIDGET(_o) );
}
void EtkWidget::hide()
{
etk_widget_hide( ETK_WIDGET(_o) );
}
void EtkWidget::hideAll()
{
etk_widget_hide_all( ETK_WIDGET(_o) );
}
bool EtkWidget::isVisible() const
{
return etk_widget_is_visible( ETK_WIDGET(_o) );
}
//==========================================================================//
// EtkContainer
//==========================================================================//
EtkContainer::EtkContainer( EtkObject* parent, const char* type, const char* name )
:EtkWidget( parent, type, name )
{
init( );
}
EtkContainer::EtkContainer (Etk_Object *o)
{
_o = o;
_managed = false;
}
EtkContainer::~EtkContainer()
{
}
void EtkContainer::add( EtkWidget* child )
{
etk_container_add( ETK_CONTAINER(_o), ETK_WIDGET(child->obj()) );
}
void EtkContainer::remove (EtkWidget *widget)
{
etk_container_remove (ETK_WIDGET (widget->obj ()));
}
void EtkContainer::removeAll ()
{
etk_container_remove_all (ETK_CONTAINER(_o));
}
void EtkContainer::setBorderWidth( int width )
{
etk_container_border_width_set( ETK_CONTAINER (_o), width);
}
int EtkContainer::getBorderWidth ()
{
return etk_container_border_width_get (ETK_CONTAINER (_o));
}
Eina_List *EtkContainer::getChildren ()
{
return etk_container_children_get (ETK_CONTAINER (_o));
}
bool EtkContainer::isChild (EtkWidget *widget)
{
return etk_container_is_child(ETK_CONTAINER (_o), ETK_WIDGET (widget->obj ()));
}
void EtkContainer::fillChildSpace (EtkWidget *child, Etk_Geometry &out_child_space, bool hfill, bool vfill, float xalign, float yalign)
{
etk_container_child_space_fill (ETK_WIDGET (child->obj ()), &out_child_space, hfill, vfill, xalign, yalign);
}
EtkContainer *EtkContainer::wrap( Etk_Object* o )
{
return new EtkContainer (o);
}
//==========================================================================//
// EtkTopLevelWidget
//==========================================================================//
@ -278,148 +123,6 @@ EtkVBox::EtkVBox( EtkObject* parent, const char* type, const char* name )
EtkVBox::~EtkVBox()
{
}
//==========================================================================//
// EtkImage
//==========================================================================//
EtkImage::EtkImage( Etk_Object *o )
{
_o = o;
_managed = false;
}
void EtkImage::setFromFile( const string &filename, const string &key )
{
etk_image_set_from_file( ETK_IMAGE( _o ), filename.c_str (), key.c_str () );
}
void EtkImage::getFile( string &outFilename, string &outKey, bool eetLoaded )
{
char *filename = NULL;
char *key = NULL;
etk_image_file_get( ETK_IMAGE( _o ), &filename, &key);
outFilename = filename;
if (key)
{
outKey = key;
eetLoaded = true;
}
else
{
eetLoaded = false;
}
}
void EtkImage::setFromEdje (const string &filename, const string &group)
{
etk_image_set_from_edje (ETK_IMAGE( _o ), filename.c_str (), group.c_str ());
}
void EtkImage::getEdje (string &outFilename, string &outGroup)
{
char *filename = NULL;
char *group = NULL;
etk_image_edje_get( ETK_IMAGE( _o ), &filename, &group);
outFilename = filename;
outGroup = group;
}
void EtkImage::setFromStock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size)
{
etk_image_set_from_stock (ETK_IMAGE( _o ), stock_id, stock_size);
}
Etk_Stock_Id EtkImage::getStockId ()
{
Etk_Stock_Id stock_id;
etk_image_stock_get (ETK_IMAGE (_o), &stock_id, NULL);
return stock_id;
}
Etk_Stock_Size EtkImage::getStockSize ()
{
Etk_Stock_Size stock_size;
etk_image_stock_get (ETK_IMAGE (_o), NULL, &stock_size);
return stock_size;
}
void EtkImage::setFromEvasObject (const EvasObject &eo)
{
etk_image_set_from_evas_object (ETK_IMAGE (_o), eo.obj ());
}
CountedPtr <EvasObject> EtkImage::getEvasObject ()
{
Evas_Object *eo = etk_image_evas_object_get (ETK_IMAGE (_o));
return CountedPtr <EvasObject> (EvasObject::wrap (eo));
}
void EtkImage::setFromData (int width, int height, void *data, bool copy)
{
etk_image_set_from_data (ETK_IMAGE (_o), width, height, data, copy);
}
void *EtkImage::getData (bool for_writing)
{
return etk_image_data_get (ETK_IMAGE (_o), for_writing);
}
Etk_Image_Source EtkImage::getSource ()
{
return etk_image_source_get (ETK_IMAGE (_o));
}
void EtkImage::update ()
{
etk_image_update (ETK_IMAGE (_o));
}
void EtkImage::rectUpdate (int x, int y, int w, int h)
{
etk_image_update_rect (ETK_IMAGE (_o), x, y, w, h);
}
int EtkImage::getWidth ()
{
int width;
etk_image_size_get (ETK_IMAGE (_o), &width, NULL);
return width;
}
int EtkImage::getHeight ()
{
int height;
etk_image_size_get (ETK_IMAGE (_o), NULL, &height);
return height;
}
void EtkImage::setAspect (bool keep_aspect)
{
etk_image_keep_aspect_set (ETK_IMAGE (_o), keep_aspect);
}
bool EtkImage::getKeepAspect ()
{
return etk_image_keep_aspect_get (ETK_IMAGE (_o));
}
void EtkImage::setRatio (double aspect_ratio)
{
etk_image_aspect_ratio_set (ETK_IMAGE (_o), aspect_ratio);
}
double EtkImage::getRatio ()
{
return etk_image_aspect_ratio_get (ETK_IMAGE (_o));
}
EtkImage *EtkImage::wrap( Etk_Object* o )
{
return new EtkImage( o );
}
//==========================================================================//
// EtkButton

View File

@ -1,10 +1,6 @@
#ifndef ETK_BASE
#define ETK_BASE
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* STL */
#include <string>
@ -13,6 +9,9 @@
#include <eflpp_evas.h>
#include <eflpp_countedptr.h>
#include "eflpp_etkcontainer.h"
#include "eflpp_etkimage.h"
/* EFL */
#include <etk/Etk.h>
@ -22,134 +21,6 @@ using std::string;
namespace efl {
class EtkObject;
class EtkWidget;
class EtkObject
{
public:
EtkObject( EtkObject* parent = 0, const char* type = "<unknown>", const char* name = 0 );
virtual ~EtkObject();
void setFillPolicy( );
void setAlignment( );
void resize( const Size& size );
public:
Etk_Object* obj() const { return _o; };
protected:
void init( );
Etk_Object* _o;
const char* _type;
bool _managed;
};
class EtkWidget : public EtkObject
{
public:
EtkWidget( EtkObject* parent = 0, const char* type = "Widget", const char* name = 0 );
virtual ~EtkWidget();
void show();
void showAll();
void hide();
void hideAll();
bool isVisible() const;
};
class EtkContainer : public EtkWidget
{
public:
EtkContainer( EtkObject* parent = 0, const char* type = "Container", const char* name = 0 );
virtual ~EtkContainer();
/**
* @brief Adds a child to the container
* @param widget the widget to add
*/
void add( EtkWidget* child );
/**
* @brief Removes a child from its container. It is equivalent to setParent (NULL)
* @param widget the widget to remove
*/
void remove (EtkWidget *widget);
/**
* @brief Unpacks all the children of the container
*/
void removeAll ();
/**
* @brief Sets the border width of a container. The border width is the amount of space left around the inside of
* the container. To add free space around the outside of a container, you can use etk_widget_padding_set()
* @param border_width the border width to set
* @see setPadding()
*/
void setBorderWidth( int );
/**
* @brief Gets the border width of the container
* @return Returns the border width of the container
*/
int getBorderWidth ();
/**
* @brief Gets the list of the children of the container. It simply calls the "childrend_get()" method of the container
* @return Returns the list of the container's children
* @note The returned list will have to be freed with eina_list_free() when you no longer need it
* @todo wrap Eina_List
*/
Eina_List *getChildren ();
/**
* @brief Gets whether the widget is a child of the container
* @param widget the widget you want to check if it is a child of the container
* @return Returns true if the widget is a child of the container, false otherwise
*/
bool isChild (EtkWidget *widget);
/**
* @brief Calls @a for_each_cb(child) for each child of the container
* @param for_each_cb the function to call
* @todo do it with sigc++
*/
//void etk_container_for_each(Etk_Container *container, void (*for_each_cb)(Etk_Widget *child))
/**
* @brief Calls @a for_each_cb(child, data) for each child of the container
* @param for_each_cb the function to call
* @param data the data to pass as the second argument of @a for_each_cb()
* @todo do it with sigc++
*/
//void etk_container_for_each_data(Etk_Container *container, void (*for_each_cb)(Etk_Widget *child, void *data), void *data)
/**
* @brief A utility function that resizes the given space according to the specified fill-policy.
* It is mainly used by container implementations
* @param child a child
* @param child_space the space for the child. It will be modified according to the fill options
* @param hfill if @a hfill == true, the child will fill the space horizontally
* @param vfill if @a vfill == true, the child will fill the space vertically
* @param xalign the horizontal alignment of the child widget in the child space (has no effect if @a hfill is true)
* @param yalign the vertical alignment of the child widget in the child space (has no effect if @a vfill is true)
*/
static void fillChildSpace (EtkWidget *child, Etk_Geometry &out_child_space, bool hfill, bool vfill, float xalign, float yalign);
/**
* @brief C object wrapper factory method
* Only for internal usage!
*/
static EtkContainer *wrap( Etk_Object* o );
private:
EtkContainer (Etk_Object *o);
};
class EtkTopLevelWidget : public EtkContainer
{
public:
@ -178,194 +49,6 @@ class EtkVBox : public EtkBox
virtual ~EtkVBox();
};
class EtkImage : public EtkWidget
{
public:
/*
Etk_Widget * etk_image_new (void)
Creates a new empty image.
Etk_Widget * etk_image_new_from_file (const char *filename, const char *key)
Creates a new image and loads the image from an image file.
Etk_Widget * etk_image_new_from_edje (const char *filename, const char *group)
Creates a new image and loads the image from an edje-file.
Etk_Widget * etk_image_new_from_stock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size)
Creates a new image and loads the image corresponding to the stock id.
Etk_Widget * etk_image_new_from_evas_object (Evas_Object *evas_object)
Creates a new image from the given evas object.
Etk_Widget * etk_image_new_from_data (int width, int height, void *data, Etk_Bool copy)
Creates a new image from the given pixel data.
*/
/**
* @brief Loads the image from a file.
* @param filename the path to the file to load
* @param key the key to load (only used if the file is an Eet file, otherwise you can set it to NULL)
*/
void setFromFile( const string &filename, const string &key );
/**
* @brief Gets the path to the file used by the image.
* @param outFilename the location where to store the path to the loaded file
* @param outKey the location where to store the key of the loaded image
* @param false if the file is not loaded from an Eet file
*/
void getFile( string &outFilename, string &outKey, bool eetLoaded );
/**
* @brief Loads the image from an edje file
* @param filename the path to the edje-file to load
* @param group the name of the edje-group to load
*/
void setFromEdje (const string &filename, const string &group);
/**
* @brief Gets the filename and the group of the edje-object used for the image
* @param outFilename the location to store the path to the edje-file used
* @param outGroup the location to store the name of the edje-group used
*/
void getEdje (string &outFilename, string &outGroup);
/**
* @brief Loads the image corresponding to the given stock-id
* @param stock_id the stock-id corresponding to the icon to load
* @param stock_size the size of the stock-icon
*/
void setFromStock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size);
/**
* @brief Gets the stock-id used by the image
* @return stock id used by the image
*/
Etk_Stock_Id getStockId ();
/**
* @brief Gets the stock-size used by the image
* @return stock size used by the image
*/
Etk_Stock_Size getStockSize ();
/**
* @brief Loads the image from an Evas object
* @param evas_object the Evas object to use. The object can be anything (image, edje object, emotion object, ...)
*/
void setFromEvasObject (const EvasObject &evas_object);
/**
* @brief Gets the Evas object used by the image. You can call this function even if you have not explicitly set the
* Evas object used by this image. For example, if you have loaded the image from a file, this function will return the
* corresponding Evas image object. You should just be careful by manipulating it (don't use Edje functions on an image
* object for example).
* @return Returns the EvasObject of the image
*/
CountedPtr <EvasObject> getEvasObject ();
/**
* @brief Sets the pixels of the image
* @param width the width of the image
* @param height the height of the image
* @param data a pointer to the pixels: the pixels have to be stored in the premul'ed ARGB format
* @param copy whether the pixels should be copied or not. If you decide not to copy the pixels, you have to make sure
* the memory area where the pixels are stored is valid during all the lifetime of the image
* @return Returns the new image widget
*/
void setFromData (int width, int height, void *data, bool copy);
/**
* @brief Gets a pointer to the image pixels. This function only works if the image has been loaded from a file or if
* you have explicitely set its pixels with etk_image_set_from_data().
* @param for_writing whether or not you want to be able to modify the pixels of the image. If so, call
* update() once you have finished.
* @return Returns a pointer to the location of the pixels (stored in premul'ed ARGB format)
* @note If the image is loaded from a file, it has to be realized. Otherwise it will return NULL
*/
void *getData (bool for_writing);
/**
* @brief Gets the source of the image (file, edje-file, stock, Evas object or pixel data)
* @return Returns the source of the image
*/
Etk_Image_Source getSource ();
/**
* @brief Updates all the pixels of the image (to be called after you have modified the pixel buffer for example).
* Same as rectUpdate(0, 0, image_width, image_height)
*/
void update ();
/**
* @brief Updates a rectangle of the pixels of the image (to be called after you have modified the pixel buffer
* for example). It only has effect on image loaded from a pixel buffer
* @param x the x position of the top-left corner of the rectangle to update
* @param y the y position of the top-left corner of the rectangle to update
* @param w the width of the rectangle to update
* @param h the height of the rectangle to update
*/
void rectUpdate (int x, int y, int w, int h);
/**
* @brief Gets the native width of the image. If the image is loaded from a file or from given pixels, it returns the
* native size of the image. If the image is loaded from an Edje file or a stock-id, it returns the minimum size of the
* Edje object (a stock image is an Edje object). Otherwise, the returned size is 0x0
* @return native width of the image
*/
int getWidth ();
/**
* @brief Gets the native height of the image. If the image is loaded from a file or from given pixels, it returns the
* native size of the image. If the image is loaded from an Edje file or a stock-id, it returns the minimum size of the
* Edje object (a stock image is an Edje object). Otherwise, the returned size is 0x0
* @return native height of the image
*/
int getHeight ();
/**
* @brief Sets if the image should keep its aspect ratio when it is resized
* @param keep_aspect if @a keep_aspect is true, the image will keep its aspect ratio when it is resized
*/
void setAspect (bool keep_aspect);
/**
* @brief Gets whether the image keeps its aspect ratio when it is resized
* @return Returns true if the image keeps its aspect ratio when it is resized
*/
bool getKeepAspect ();
/**
* @brief Sets (forces) the aspect ratio of the image. You can use this function for example to set the aspect-ratio
* when you set the image from an Evas object with etk_image_set_from_evas_object().
* @param aspect_ratio the aspect ratio to set, or 0.0 to make Etk calculates automatically the aspect ratio
*/
void setRatio (double aspect_ratio);
/**
* @brief Gets the aspect ratio you set to the image. If no aspect ratio has been set, it will return 0.0.
* To know the native aspect ratio, call etk_image_size_get() to get the native size of the image and calculate the
* aspect ratio from these values.
* @return Returns the aspect ratio you set to the image, or 0.0 if no aspect ratio has been set
*/
double getRatio ();
/**
* @brief Copies the image @a src_image to @a dest_image
* @param dest_image the destination image
* @param src_image the image to copy
* @note If @a src_image is an edje image, the current state of the edje animation won't be copied
*/
/*
TODO: copy constructor:
void etk_image_copy (Etk_Image *dest_image, Etk_Image *src_image)
*/
/**
* @brief C object wrapper factory method
* Only for internal usage!
*/
static EtkImage *wrap( Etk_Object* o );
private:
EtkImage( Etk_Object *o );
};
/// \todo wrap C enum types to C++
class EtkButton : public EtkBox
{

View File

@ -0,0 +1,73 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "eflpp_etkcontainer.h"
/* EFL */
#include <etk/etk_container.h>
namespace efl {
EtkContainer::EtkContainer( EtkObject* parent, const char* type, const char* name )
:EtkWidget( parent, type, name )
{
init( );
}
EtkContainer::EtkContainer (Etk_Object *o)
{
_o = o;
_managed = false;
}
EtkContainer::~EtkContainer()
{
}
void EtkContainer::add( EtkWidget* child )
{
etk_container_add( ETK_CONTAINER(_o), ETK_WIDGET(child->obj()) );
}
void EtkContainer::remove (EtkWidget *widget)
{
etk_container_remove (ETK_WIDGET (widget->obj ()));
}
void EtkContainer::removeAll ()
{
etk_container_remove_all (ETK_CONTAINER(_o));
}
void EtkContainer::setBorderWidth( int width )
{
etk_container_border_width_set( ETK_CONTAINER (_o), width);
}
int EtkContainer::getBorderWidth ()
{
return etk_container_border_width_get (ETK_CONTAINER (_o));
}
Eina_List *EtkContainer::getChildren ()
{
return etk_container_children_get (ETK_CONTAINER (_o));
}
bool EtkContainer::isChild (EtkWidget *widget)
{
return etk_container_is_child(ETK_CONTAINER (_o), ETK_WIDGET (widget->obj ()));
}
void EtkContainer::fillChildSpace (EtkWidget *child, Etk_Geometry &out_child_space, bool hfill, bool vfill, float xalign, float yalign)
{
etk_container_child_space_fill (ETK_WIDGET (child->obj ()), &out_child_space, hfill, vfill, xalign, yalign);
}
EtkContainer *EtkContainer::wrap( Etk_Object* o )
{
return new EtkContainer (o);
}
} // end namespace efl

View File

@ -0,0 +1,109 @@
#ifndef EFLPP_ETKCONTAINER_H
#define EFLPP_ETKCONTAINER_H
/* STL */
#include <string>
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_countedptr.h>
#include "eflpp_etkwidget.h"
using std::string;
namespace efl {
class EtkContainer : public EtkWidget
{
public:
EtkContainer( EtkObject* parent = 0, const char* type = "Container", const char* name = 0 );
virtual ~EtkContainer();
/**
* @brief Adds a child to the container
* @param widget the widget to add
*/
void add( EtkWidget* child );
/**
* @brief Removes a child from its container. It is equivalent to setParent (NULL)
* @param widget the widget to remove
*/
void remove (EtkWidget *widget);
/**
* @brief Unpacks all the children of the container
*/
void removeAll ();
/**
* @brief Sets the border width of a container. The border width is the amount of space left around the inside of
* the container. To add free space around the outside of a container, you can use etk_widget_padding_set()
* @param border_width the border width to set
* @see setPadding()
*/
void setBorderWidth( int );
/**
* @brief Gets the border width of the container
* @return Returns the border width of the container
*/
int getBorderWidth ();
/**
* @brief Gets the list of the children of the container. It simply calls the "childrend_get()" method of the container
* @return Returns the list of the container's children
* @note The returned list will have to be freed with eina_list_free() when you no longer need it
* @todo wrap Eina_List
*/
Eina_List *getChildren ();
/**
* @brief Gets whether the widget is a child of the container
* @param widget the widget you want to check if it is a child of the container
* @return Returns true if the widget is a child of the container, false otherwise
*/
bool isChild (EtkWidget *widget);
/**
* @brief Calls @a for_each_cb(child) for each child of the container
* @param for_each_cb the function to call
* @todo do it with sigc++
*/
//void etk_container_for_each(Etk_Container *container, void (*for_each_cb)(Etk_Widget *child))
/**
* @brief Calls @a for_each_cb(child, data) for each child of the container
* @param for_each_cb the function to call
* @param data the data to pass as the second argument of @a for_each_cb()
* @todo do it with sigc++
*/
//void etk_container_for_each_data(Etk_Container *container, void (*for_each_cb)(Etk_Widget *child, void *data), void *data)
/**
* @brief A utility function that resizes the given space according to the specified fill-policy.
* It is mainly used by container implementations
* @param child a child
* @param child_space the space for the child. It will be modified according to the fill options
* @param hfill if @a hfill == true, the child will fill the space horizontally
* @param vfill if @a vfill == true, the child will fill the space vertically
* @param xalign the horizontal alignment of the child widget in the child space (has no effect if @a hfill is true)
* @param yalign the vertical alignment of the child widget in the child space (has no effect if @a vfill is true)
*/
static void fillChildSpace (EtkWidget *child, Etk_Geometry &out_child_space, bool hfill, bool vfill, float xalign, float yalign);
/**
* @brief C object wrapper factory method
* Only for internal usage!
*/
static EtkContainer *wrap( Etk_Object* o );
private:
EtkContainer (Etk_Object *o);
};
} // end namespace efl
#endif // EFLPP_ETKCONTAINER_H

147
src/etk/eflpp_etkimage.cpp Normal file
View File

@ -0,0 +1,147 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "eflpp_etkimage.h"
namespace efl {
EtkImage::EtkImage( Etk_Object *o )
{
_o = o;
_managed = false;
}
void EtkImage::setFromFile( const string &filename, const string &key )
{
etk_image_set_from_file( ETK_IMAGE( _o ), filename.c_str (), key.c_str () );
}
void EtkImage::getFile( string &outFilename, string &outKey, bool eetLoaded )
{
char *filename = NULL;
char *key = NULL;
etk_image_file_get( ETK_IMAGE( _o ), &filename, &key);
outFilename = filename;
if (key)
{
outKey = key;
eetLoaded = true;
}
else
{
eetLoaded = false;
}
}
void EtkImage::setFromEdje (const string &filename, const string &group)
{
etk_image_set_from_edje (ETK_IMAGE( _o ), filename.c_str (), group.c_str ());
}
void EtkImage::getEdje (string &outFilename, string &outGroup)
{
char *filename = NULL;
char *group = NULL;
etk_image_edje_get( ETK_IMAGE( _o ), &filename, &group);
outFilename = filename;
outGroup = group;
}
void EtkImage::setFromStock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size)
{
etk_image_set_from_stock (ETK_IMAGE( _o ), stock_id, stock_size);
}
Etk_Stock_Id EtkImage::getStockId ()
{
Etk_Stock_Id stock_id;
etk_image_stock_get (ETK_IMAGE (_o), &stock_id, NULL);
return stock_id;
}
Etk_Stock_Size EtkImage::getStockSize ()
{
Etk_Stock_Size stock_size;
etk_image_stock_get (ETK_IMAGE (_o), NULL, &stock_size);
return stock_size;
}
void EtkImage::setFromEvasObject (const EvasObject &eo)
{
etk_image_set_from_evas_object (ETK_IMAGE (_o), eo.obj ());
}
CountedPtr <EvasObject> EtkImage::getEvasObject ()
{
Evas_Object *eo = etk_image_evas_object_get (ETK_IMAGE (_o));
return CountedPtr <EvasObject> (EvasObject::wrap (eo));
}
void EtkImage::setFromData (int width, int height, void *data, bool copy)
{
etk_image_set_from_data (ETK_IMAGE (_o), width, height, data, copy);
}
void *EtkImage::getData (bool for_writing)
{
return etk_image_data_get (ETK_IMAGE (_o), for_writing);
}
Etk_Image_Source EtkImage::getSource ()
{
return etk_image_source_get (ETK_IMAGE (_o));
}
void EtkImage::update ()
{
etk_image_update (ETK_IMAGE (_o));
}
void EtkImage::rectUpdate (int x, int y, int w, int h)
{
etk_image_update_rect (ETK_IMAGE (_o), x, y, w, h);
}
int EtkImage::getWidth ()
{
int width;
etk_image_size_get (ETK_IMAGE (_o), &width, NULL);
return width;
}
int EtkImage::getHeight ()
{
int height;
etk_image_size_get (ETK_IMAGE (_o), NULL, &height);
return height;
}
void EtkImage::setAspect (bool keep_aspect)
{
etk_image_keep_aspect_set (ETK_IMAGE (_o), keep_aspect);
}
bool EtkImage::getKeepAspect ()
{
return etk_image_keep_aspect_get (ETK_IMAGE (_o));
}
void EtkImage::setRatio (double aspect_ratio)
{
etk_image_aspect_ratio_set (ETK_IMAGE (_o), aspect_ratio);
}
double EtkImage::getRatio ()
{
return etk_image_aspect_ratio_get (ETK_IMAGE (_o));
}
EtkImage *EtkImage::wrap( Etk_Object* o )
{
return new EtkImage( o );
}
} // end namespace efl

210
src/etk/eflpp_etkimage.h Normal file
View File

@ -0,0 +1,210 @@
#ifndef EFLPP_ETKIMAGE_H
#define EFLPP_ETKIMAGE_H
/* STL */
#include <string>
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_countedptr.h>
#include "eflpp_etkwidget.h"
/* EFL */
#include <etk/etk_image.h>
using std::string;
namespace efl {
class EtkImage : public EtkWidget
{
public:
/*
Etk_Widget * etk_image_new (void)
Creates a new empty image.
Etk_Widget * etk_image_new_from_file (const char *filename, const char *key)
Creates a new image and loads the image from an image file.
Etk_Widget * etk_image_new_from_edje (const char *filename, const char *group)
Creates a new image and loads the image from an edje-file.
Etk_Widget * etk_image_new_from_stock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size)
Creates a new image and loads the image corresponding to the stock id.
Etk_Widget * etk_image_new_from_evas_object (Evas_Object *evas_object)
Creates a new image from the given evas object.
Etk_Widget * etk_image_new_from_data (int width, int height, void *data, Etk_Bool copy)
Creates a new image from the given pixel data.
*/
/**
* @brief Loads the image from a file.
* @param filename the path to the file to load
* @param key the key to load (only used if the file is an Eet file, otherwise you can set it to NULL)
*/
void setFromFile( const string &filename, const string &key );
/**
* @brief Gets the path to the file used by the image.
* @param outFilename the location where to store the path to the loaded file
* @param outKey the location where to store the key of the loaded image
* @param false if the file is not loaded from an Eet file
*/
void getFile( string &outFilename, string &outKey, bool eetLoaded );
/**
* @brief Loads the image from an edje file
* @param filename the path to the edje-file to load
* @param group the name of the edje-group to load
*/
void setFromEdje (const string &filename, const string &group);
/**
* @brief Gets the filename and the group of the edje-object used for the image
* @param outFilename the location to store the path to the edje-file used
* @param outGroup the location to store the name of the edje-group used
*/
void getEdje (string &outFilename, string &outGroup);
/**
* @brief Loads the image corresponding to the given stock-id
* @param stock_id the stock-id corresponding to the icon to load
* @param stock_size the size of the stock-icon
*/
void setFromStock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size);
/**
* @brief Gets the stock-id used by the image
* @return stock id used by the image
*/
Etk_Stock_Id getStockId ();
/**
* @brief Gets the stock-size used by the image
* @return stock size used by the image
*/
Etk_Stock_Size getStockSize ();
/**
* @brief Loads the image from an Evas object
* @param evas_object the Evas object to use. The object can be anything (image, edje object, emotion object, ...)
*/
void setFromEvasObject (const EvasObject &evas_object);
/**
* @brief Gets the Evas object used by the image. You can call this function even if you have not explicitly set the
* Evas object used by this image. For example, if you have loaded the image from a file, this function will return the
* corresponding Evas image object. You should just be careful by manipulating it (don't use Edje functions on an image
* object for example).
* @return Returns the EvasObject of the image
*/
CountedPtr <EvasObject> getEvasObject ();
/**
* @brief Sets the pixels of the image
* @param width the width of the image
* @param height the height of the image
* @param data a pointer to the pixels: the pixels have to be stored in the premul'ed ARGB format
* @param copy whether the pixels should be copied or not. If you decide not to copy the pixels, you have to make sure
* the memory area where the pixels are stored is valid during all the lifetime of the image
* @return Returns the new image widget
*/
void setFromData (int width, int height, void *data, bool copy);
/**
* @brief Gets a pointer to the image pixels. This function only works if the image has been loaded from a file or if
* you have explicitely set its pixels with etk_image_set_from_data().
* @param for_writing whether or not you want to be able to modify the pixels of the image. If so, call
* update() once you have finished.
* @return Returns a pointer to the location of the pixels (stored in premul'ed ARGB format)
* @note If the image is loaded from a file, it has to be realized. Otherwise it will return NULL
*/
void *getData (bool for_writing);
/**
* @brief Gets the source of the image (file, edje-file, stock, Evas object or pixel data)
* @return Returns the source of the image
*/
Etk_Image_Source getSource ();
/**
* @brief Updates all the pixels of the image (to be called after you have modified the pixel buffer for example).
* Same as rectUpdate(0, 0, image_width, image_height)
*/
void update ();
/**
* @brief Updates a rectangle of the pixels of the image (to be called after you have modified the pixel buffer
* for example). It only has effect on image loaded from a pixel buffer
* @param x the x position of the top-left corner of the rectangle to update
* @param y the y position of the top-left corner of the rectangle to update
* @param w the width of the rectangle to update
* @param h the height of the rectangle to update
*/
void rectUpdate (int x, int y, int w, int h);
/**
* @brief Gets the native width of the image. If the image is loaded from a file or from given pixels, it returns the
* native size of the image. If the image is loaded from an Edje file or a stock-id, it returns the minimum size of the
* Edje object (a stock image is an Edje object). Otherwise, the returned size is 0x0
* @return native width of the image
*/
int getWidth ();
/**
* @brief Gets the native height of the image. If the image is loaded from a file or from given pixels, it returns the
* native size of the image. If the image is loaded from an Edje file or a stock-id, it returns the minimum size of the
* Edje object (a stock image is an Edje object). Otherwise, the returned size is 0x0
* @return native height of the image
*/
int getHeight ();
/**
* @brief Sets if the image should keep its aspect ratio when it is resized
* @param keep_aspect if @a keep_aspect is true, the image will keep its aspect ratio when it is resized
*/
void setAspect (bool keep_aspect);
/**
* @brief Gets whether the image keeps its aspect ratio when it is resized
* @return Returns true if the image keeps its aspect ratio when it is resized
*/
bool getKeepAspect ();
/**
* @brief Sets (forces) the aspect ratio of the image. You can use this function for example to set the aspect-ratio
* when you set the image from an Evas object with etk_image_set_from_evas_object().
* @param aspect_ratio the aspect ratio to set, or 0.0 to make Etk calculates automatically the aspect ratio
*/
void setRatio (double aspect_ratio);
/**
* @brief Gets the aspect ratio you set to the image. If no aspect ratio has been set, it will return 0.0.
* To know the native aspect ratio, call etk_image_size_get() to get the native size of the image and calculate the
* aspect ratio from these values.
* @return Returns the aspect ratio you set to the image, or 0.0 if no aspect ratio has been set
*/
double getRatio ();
/**
* @brief Copies the image @a src_image to @a dest_image
* @param dest_image the destination image
* @param src_image the image to copy
* @note If @a src_image is an edje image, the current state of the edje animation won't be copied
*/
/*
TODO: copy constructor:
void etk_image_copy (Etk_Image *dest_image, Etk_Image *src_image)
*/
/**
* @brief C object wrapper factory method
* Only for internal usage!
*/
static EtkImage *wrap( Etk_Object* o );
private:
EtkImage( Etk_Object *o );
};
} // end namespace efl
#endif // EFLPP_ETKIMAGE_H

View File

@ -0,0 +1,61 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cassert>
#include <etk/etk_window.h>
#include <etk/etk_button.h>
#include "eflpp_etkobject.h"
using namespace std;
namespace efl {
EtkObject::EtkObject( EtkObject* parent, const char* type, const char* name )
:_o( 0 )
{
cout << "EtkObject::EtkObject - generating object '" << ( name ? name : "<unknown>" ) << "' (" << type << ")" << endl;
if ( strcmp( type, "TopLevelWidget" ) == 0 )
{
assert( not "implemented" );
//_o = ETK_OBJECT( etk_widget_new() );
}
else if ( strcmp( type, "Embed" ) == 0 )
{
// already created
}
else if ( strcmp( type, "Window" ) == 0 )
{
_o = ETK_OBJECT( etk_window_new() );
}
else if ( strcmp( type, "Button" ) == 0 )
{
_o = ETK_OBJECT( etk_button_new() );
}
else
assert( not "a known widget" );
}
EtkObject::~EtkObject()
{
}
void EtkObject::resize( const Size& size )
{
etk_widget_size_request_set( ETK_WIDGET(_o), size.width(), size.height() );
}
void EtkObject::setFillPolicy( )
{
}
void EtkObject::setAlignment( )
{
}
void EtkObject::init( )
{
_managed = true;
}
} // end namespace efl

44
src/etk/eflpp_etkobject.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef EFLPP_ETKOBJECT_H
#define EFLPP_ETKOBJECT_H
/* STL */
#include <string>
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_countedptr.h>
/* EFL */
#include <etk/etk_object.h>
using std::string;
namespace efl {
class EtkObject
{
public:
EtkObject( EtkObject* parent = 0, const char* type = "<unknown>", const char* name = 0 );
virtual ~EtkObject();
void setFillPolicy( );
void setAlignment( );
void resize( const Size& size );
public:
Etk_Object* obj() const { return _o; };
protected:
void init( );
Etk_Object* _o;
const char* _type;
bool _managed;
};
} // end namespace efl
#endif // EFLPP_ETKOBJECT_H

View File

@ -0,0 +1,47 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "eflpp_etkwidget.h"
/* EFL */
#include <etk/etk_widget.h>
namespace efl {
EtkWidget::EtkWidget( EtkObject* parent, const char* type, const char* name )
:EtkObject( parent, type, name )
{
init( );
}
EtkWidget::~EtkWidget()
{
}
void EtkWidget::show()
{
etk_widget_show( ETK_WIDGET(_o) );
}
void EtkWidget::showAll()
{
etk_widget_show_all( ETK_WIDGET(_o) );
}
void EtkWidget::hide()
{
etk_widget_hide( ETK_WIDGET(_o) );
}
void EtkWidget::hideAll()
{
etk_widget_hide_all( ETK_WIDGET(_o) );
}
bool EtkWidget::isVisible() const
{
return etk_widget_is_visible( ETK_WIDGET(_o) );
}
} // end namespace efl

34
src/etk/eflpp_etkwidget.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef EFLPP_ETKWIDGET_H
#define EFLPP_ETKWIDGET_H
/* STL */
#include <string>
/* EFL++ */
#include <eflpp_common.h>
#include <eflpp_evas.h>
#include <eflpp_countedptr.h>
#include "eflpp_etkobject.h"
using std::string;
namespace efl {
class EtkWidget : public EtkObject
{
public:
EtkWidget( EtkObject* parent = 0, const char* type = "Widget", const char* name = 0 );
virtual ~EtkWidget();
void show();
void showAll();
void hide();
void hideAll();
bool isVisible() const;
};
} // end namespace efl
#endif // EFLPP_ETKWIDGET_H