/* Copyright (C) 2011 Samsung Electronics This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ewk_view_h #define ewk_view_h #include <Evas.h> #include <WebKit2/WKBase.h> #ifdef __cplusplus extern "C" { #endif typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data; typedef struct _Ewk_View_Smart_Class Ewk_View_Smart_Class; /// Ewk view's class, to be overridden by sub-classes. struct _Ewk_View_Smart_Class { Evas_Smart_Class sc; /**< all but 'data' is free to be changed. */ unsigned long version; // event handling: // - returns true if handled // - if overridden, have to call parent method if desired Eina_Bool (*focus_in)(Ewk_View_Smart_Data *sd); Eina_Bool (*focus_out)(Ewk_View_Smart_Data *sd); Eina_Bool (*mouse_wheel)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Wheel *ev); Eina_Bool (*mouse_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Down *ev); Eina_Bool (*mouse_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Up *ev); Eina_Bool (*mouse_move)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Move *ev); Eina_Bool (*key_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Key_Down *ev); Eina_Bool (*key_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Key_Up *ev); }; /** * The version you have to put into the version field * in the @a Ewk_View_Smart_Class structure. */ #define EWK_VIEW_SMART_CLASS_VERSION 1UL /** * Initializer for whole Ewk_View_Smart_Class structure. * * @param smart_class_init initializer to use for the "base" field * (Evas_Smart_Class). * * @see EWK_VIEW_SMART_CLASS_INIT_NULL * @see EWK_VIEW_SMART_CLASS_INIT_VERSION * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION */ #define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0} /** * Initializer to zero a whole Ewk_View_Smart_Class structure. * * @see EWK_VIEW_SMART_CLASS_INIT_VERSION * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION * @see EWK_VIEW_SMART_CLASS_INIT */ #define EWK_VIEW_SMART_CLASS_INIT_NULL EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL) /** * Initializer to zero a whole Ewk_View_Smart_Class structure and set * name and version. * * Similar to EWK_VIEW_SMART_CLASS_INIT_NULL, but will set version field of * Evas_Smart_Class (base field) to latest EVAS_SMART_CLASS_VERSION and name * to the specific value. * * It will keep a reference to name field as a "const char *", that is, * name must be available while the structure is used (hint: static or global!) * and will not be modified. * * @see EWK_VIEW_SMART_CLASS_INIT_NULL * @see EWK_VIEW_SMART_CLASS_INIT_VERSION * @see EWK_VIEW_SMART_CLASS_INIT */ #define EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(name) EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name)) typedef struct _Ewk_View_Private_Data Ewk_View_Private_Data; /** * @brief Contains an internal View data. * * It is to be considered private by users, but may be extended or * changed by sub-classes (that's why it's in public header file). */ struct _Ewk_View_Smart_Data { Evas_Object_Smart_Clipped_Data base; const Ewk_View_Smart_Class* api; /**< reference to casted class instance */ Evas_Object* self; /**< reference to owner object */ Evas_Object* image; /**< reference to evas_object_image for drawing web contents */ Ewk_View_Private_Data* priv; /**< should never be accessed, c++ stuff */ struct { Evas_Coord x, y, w, h; /**< last used viewport */ } view; struct { /**< what changed since last smart_calculate */ Eina_Bool any:1; Eina_Bool size:1; Eina_Bool position:1; } changed; }; /** * Creates a new EFL WebKit View object. * * @param e canvas object where to create the view object * @param context WKContext's Reference pointer * @param page_group WKPageGroup's Reference pointer * * @return view object on success or @c 0 on failure */ EAPI Evas_Object* ewk_view_add(Evas* e, WKContextRef context, WKPageGroupRef page_group); /** * Gets the WKPageRef of this view. * * @param o the view object to get the WKPageRef * * @return the WKPageRef of this view */ EAPI WKPageRef ewk_view_page_get(Evas_Object* o); #ifdef __cplusplus } #endif #endif // ewk_view_h