// EXTERNAL INCLUDES
#include <boost/bind.hpp>
-#include <Ecore_IMF.h>
-#include <Ecore_X.h>
#include <dali/dali.h>
#include <dali/integration-api/debug.h>
void Deactivate();
void Reset();
- Ecore_IMF_Context* GetContext();
bool RestoreAfterFocusLost() const;
void SetRestoreAferFocusLost( bool toggle );
- void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
- void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
- Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
- void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
void NotifyCursorPosition();
int GetCursorPosition();
void SetCursorPosition( unsigned int cursorPosition );
ImfManager& operator=( ImfManager& );
private:
- Ecore_IMF_Context* mIMFContext;
int mIMFCursorPosition;
std::string mSurroundingText;
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
};
-
-namespace
-{
-
-// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
-size_t Utf8SequenceLength(const unsigned char leadByte)
-{
- size_t length = 0;
-
- if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
- {
- length = 1;
- }
- else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
- {
- length = 2;
- }
- else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
- {
- length = 3;
- }
- else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
- {
- length = 4;
- }
-
- return length;
-}
-
-// Static function calls used by ecore 'c' style callback registration
-void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- imfManager->CommitReceived( data, imfContext, event_info );
- }
-}
-
-void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- imfManager->PreEditChanged( data, imfContext, event_info );
- }
-}
-
-Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition );
- }
- else
- {
- return false;
- }
-}
-
-/**
- * Called when an IMF delete surrounding event is received.
- * Here we tell the application that it should delete a certain range.
- */
-void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- imfManager->DeleteSurrounding( data, imfContext, event_info );
- }
-}
-
-} // unnamed namespace
-
Dali::ImfManager Dali::Internal::Adaptor::ImfManager::mToolkitImfManager;
-
Dali::ImfManager ImfManager::Get()
{
Dali::ImfManager manager;
}
ImfManager::ImfManager( /*Ecore_X_Window ecoreXwin*/ )
-: mIMFContext(),
- mIMFCursorPosition( 0 ),
+: mIMFCursorPosition( 0 ),
mSurroundingText(""),
mRestoreAfterFocusLost( false ),
mIdleCallbackConnected( false ),
mKeyEvents()
{
- //ecore_imf_init();
CreateContext( /*ecoreXwin*/ );
ConnectCallbacks();
- //VirtualKeyboard::ConnectCallbacks( mIMFContext );
}
ImfManager::~ImfManager()
{
- //VirtualKeyboard::DisconnectCallbacks( mIMFContext );
DisconnectCallbacks();
DeleteContext();
- //ecore_imf_shutdown();
}
void ImfManager::CreateContext( /*Ecore_X_Window ecoreXwin*/ )
// Callbacks for predicitive text support.
void ImfManager::ConnectCallbacks()
{
- //if ( mIMFContext ) {
- //ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
- //ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
- //ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
- //}
}
void ImfManager::DisconnectCallbacks()
{
- // if ( mIMFContext )
- // {
- // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
- // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
- // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
- // }
}
void ImfManager::Activate()
{
- // // Reset mIdleCallbackConnected
- // mIdleCallbackConnected = false;
-
- // if ( mIMFContext )
- // {
- // ecore_imf_context_focus_in( mIMFContext );
- // // emit keyboard activated signal
- // Dali::ImfManager handle( this );
- // mActivatedSignalV2.Emit( handle );
- // }
}
void ImfManager::Deactivate()
{
- // if( mIMFContext )
- // {
- // Reset();
- // ecore_imf_context_focus_out( mIMFContext );
- // }
- // // Reset mIdleCallbackConnected
- // mIdleCallbackConnected = false;
}
void ImfManager::Reset()
{
- // if ( mIMFContext )
- // {
- // ecore_imf_context_reset( mIMFContext );
- // }
-}
-
-Ecore_IMF_Context* ImfManager::GetContext()
-{
- //return mIMFContext;
- return NULL;
}
bool ImfManager::RestoreAfterFocusLost() const
mRestoreAfterFocusLost = toggle;
}
-void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info )
-{
- // char *preEditString( NULL );
- // int cursorPosition( 0 );
- // Eina_List *attrs = NULL;
- // Eina_List *l = NULL;
-
- // Ecore_IMF_Preedit_Attr *attr;
-
- // // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
- // // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
- // ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
- // if ( attrs )
- // {
- // // iterate through the list of attributes getting the type, start and end position.
- // for ( l = attrs, (attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ); l; l = eina_list_next(l), ( attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ))
- // {
- // if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
- // {
- // // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
- // size_t visualCharacterIndex = 0;
- // size_t byteIndex = 0;
- // // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
- // while ( preEditString[byteIndex] != '\0' )
- // {
- // // attr->end_index is provided as a byte position not character and we need to know the character position.
- // size_t currentSequenceLength = Utf8SequenceLength(preEditString[byteIndex]); // returns number of bytes used to represent character.
- // if ( byteIndex == attr->end_index )
- // {
- // cursorPosition = visualCharacterIndex;
- // break;
- // // end loop as found cursor position that matches byte position
- // }
- // else
- // {
- // byteIndex += currentSequenceLength; // jump to next character
- // visualCharacterIndex++; // increment character count so we know our position for when we get a match
- // }
- // DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
- // }
- // }
- // }
- // }
- // if ( Dali::Adaptor::IsAvailable() )
- // {
- // std::string keyString ( preEditString );
- // int numberOfChars( 0 );
- // Dali::ImfManager handle( this );
- // Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::PREEDIT, keyString, cursorPosition, numberOfChars );
- // Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
- // if ( callbackData.update )
- // {
- // SetCursorPosition( callbackData.cursorPosition );
- // SetSurroundingText( callbackData.currentText );
- // NotifyCursorPosition();
- // }
- // if ( callbackData.preeditResetRequired )
- // {
- // Reset();
- // }
- // }
- // free( preEditString );
-}
-
-void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info )
-{
- // if ( Dali::Adaptor::IsAvailable() )
- // {
- // const std::string keyString( (char *)event_info );
- // const int cursorOffset( 0 );
- // const int numberOfChars( 0 );
-
- // Dali::ImfManager handle( this );
- // Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars );
- // Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
-
- // if ( callbackData.update )
- // {
- // SetCursorPosition( callbackData.cursorPosition );
- // SetSurroundingText( callbackData.currentText );
-
- // NotifyCursorPosition();
- // }
- // }
-}
-
-/**
- * Called when an IMF retrieve surround event is received.
- * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
- * We need to signal the application to tell us this information.
- */
-Eina_Bool ImfManager::RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
-{
- // std::string keyString ( "" );
- // int cursorOffset( 0 );
- // int numberOfChars( 0 );
- // Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars );
- // Dali::ImfManager handle( this );
- // mEventSignalV2.Emit( handle, imfData );
- // if ( text )
- // {
- // std::string surroundingText( GetSurroundingText() );
- // if ( !surroundingText.empty() )
- // {
- // *text = strdup( surroundingText.c_str() );
- // }
- // else
- // {
- // *text = strdup( "" );
- // }
- // }
- // if ( cursorPosition )
- // {
- // *cursorPosition = GetCursorPosition();
- // }
- return EINA_TRUE;
-}
-
-/**
- * Called when an IMF delete surrounding event is received.
- * Here we tell the application that it should delete a certain range.
- */
-void ImfManager::DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- // if ( Dali::Adaptor::IsAvailable() )
- // {
- // Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = (Ecore_IMF_Event_Delete_Surrounding*) event_info;
- // const std::string keyString( "" );
- // const int cursorOffset( deleteSurroundingEvent->offset );
- // const int numberOfChars( deleteSurroundingEvent->n_chars );
- // Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars );
- // Dali::ImfManager handle( this );
- // mEventSignalV2.Emit( handle, imfData );
- // }
-}
-
void ImfManager::NotifyCursorPosition()
{
- // if ( mIMFContext )
- // {
- // ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
- // }
}
int ImfManager::GetCursorPosition()
ImfContext ImfManager::GetContext()
{
- return reinterpret_cast<ImfContext>( Internal::Adaptor::ImfManager::GetImplementation(*this).GetContext() );
+ return NULL;
}
void ImfManager::Activate()
#include "toolkit-timer.h"
-#include <Ecore.h>
-
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/signals/dali-signal-v2.h>
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Timer;
+
+typedef IntrusivePtr<Timer> TimerPtr;
+
+/**
+ * Implementation of the timer
+ */
+class Timer : public BaseObject
+{
+public:
+ static TimerPtr New( unsigned int milliSec );
+ Timer( unsigned int milliSec );
+ virtual ~Timer();
+
+ void Start();
+ void Stop();
+ void SetInterval( unsigned int interval );
+ unsigned int GetInterval() const;
+ bool IsRunning() const;
+ bool Tick();
+
+public: // Signals
+
+ Dali::Timer::TimerSignalV2& TickSignal();
+
+private: // Implementation
+
+ // not implemented
+ Timer( const Timer& );
+ Timer& operator=( const Timer& );
+
+private: // Data
+
+ Dali::Timer::TimerSignalV2 mTickSignal;
+ unsigned int mInterval;
+};
+
+inline Timer& GetImplementation(Dali::Timer& timer)
+{
+ DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
+
+ BaseObject& handle = timer.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Timer&>(handle);
+}
+
+inline const Timer& GetImplementation(const Dali::Timer& timer)
+{
+ DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
+
+ const BaseObject& handle = timer.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Timer&>(handle);
+}
+
+TimerPtr Timer::New( unsigned int milliSec )
+{
+ TimerPtr timerImpl = new Timer(10);
+ return timerImpl;
+}
+
+Timer::Timer( unsigned int milliSec )
+: mInterval( milliSec )
+{
+}
+
+Timer::~Timer()
+{
+}
-namespace
+void Timer::Start()
{
-bool ecore_timer_running = false;
-Ecore_Task_Cb timer_callback_func=NULL;
-const void* timer_callback_data=NULL;
-int timerId = 0;
-}// anon namespace
+}
-extern "C"
+void Timer::Stop()
{
-Ecore_Timer* ecore_timer_add(double in,
- Ecore_Task_Cb func,
- const void *data)
+}
+
+void Timer::SetInterval( unsigned int interval )
{
- ecore_timer_running = true;
- timer_callback_func = func;
- timer_callback_data = data;
- timerId += sizeof(Ecore_Timer*);
- return (Ecore_Timer*)timerId;
+ mInterval = interval;
}
-void* ecore_timer_del(Ecore_Timer *timer)
+unsigned int Timer::GetInterval() const
{
- ecore_timer_running = false;
- timer_callback_func = NULL;
- return NULL;
+ return mInterval;
}
+bool Timer::IsRunning() const
+{
+ return true;
}
+
+bool Timer::Tick()
+{
+ return false;
+}
+
+Dali::Timer::TimerSignalV2& Timer::TickSignal()
+{
+ return mTickSignal;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+/********************************************************************************/
+/********************************* PUBLIC CLASS *******************************/
+/********************************************************************************/
+
+Timer::Timer()
+{
+
+}
+
+Timer Timer::New( unsigned int milliSec )
+{
+ Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec );
+ return Timer(internal.Get());
+}
+
+Timer::Timer( const Timer& timer )
+:BaseHandle( timer )
+{
+}
+
+Timer& Timer::operator=( const Timer& timer )
+{
+ // check self assignment
+ if( *this != timer )
+ {
+ BaseHandle::operator=(timer);
+ }
+ return *this;
+}
+
+Timer::~Timer()
+{
+}
+
+void Timer::Start()
+{
+ Internal::Adaptor::GetImplementation( *this ).Start();
+}
+
+void Timer::Stop()
+{
+ Internal::Adaptor::GetImplementation( *this ).Stop();
+}
+
+void Timer::SetInterval( unsigned int milliSec )
+{
+ Internal::Adaptor::GetImplementation( *this ).SetInterval( milliSec );
+}
+
+unsigned int Timer::GetInterval() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetInterval();
+}
+
+bool Timer::IsRunning() const
+{
+ return true;
+}
+
+Timer::TimerSignalV2& Timer::TickSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).TickSignal();
+}
+
+Timer::Timer(Internal::Adaptor::Timer* timer)
+: BaseHandle(timer)
+{
+}
+
+} // namespace Dali
+