// EXTERNAL INCLUDES
#include <algorithm>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
void Show()
{
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) to show the keyboard
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
if( ImfManager::IsAvailable() /* We do not want to create an ImfManager instance*/ )
{
Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "IMF IsVisible\n" );
Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
void EnablePrediction(const bool enable)
{
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when enabling prediction
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
if ( ImfManager::IsAvailable() /* We do not want to create an instance of ImfManger */ )
{
Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
width = height = xPos = yPos = 0;
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) as we may need to do some size related setup in the application
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
if ( imfManager )
{
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
return Internal::Adaptor::ImfManager::Get();
}
-ImfContext ImfManager::GetContext()
-{
- return reinterpret_cast<ImfContext>( Internal::Adaptor::ImfManager::GetImplementation(*this).GetContext() );
-}
-
void ImfManager::Activate()
{
Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
}
-int ImfManager::GetCursorPosition()
+unsigned int ImfManager::GetCursorPosition() const
{
return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
}
}
}
-// TODO: Temporary patch to hidden ecore dependency. Must fix it.
-typedef void* ImfContext;
-
/**
* @brief The ImfManager class
*
* @brief Default Constructor.
*/
ImfEventData()
- : eventName( VOID ),
- predictiveString(""),
+ : predictiveString(),
+ eventName( VOID ),
cursorOffset( 0 ),
numberOfChars ( 0 )
{
* @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
* @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
*/
- ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
- : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
+ ImfEventData( ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset, int aNumberOfChars )
+ : predictiveString( aPredictiveString ),
+ eventName( aEventName ),
+ cursorOffset( aCursorOffset ),
+ numberOfChars( aNumberOfChars )
{
}
// Data
- ImfEvent eventName; ///< The name of the event from the IMF.
std::string predictiveString; ///< The pre-edit or commit string.
- int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
- int numberOfChars; ///< number of characters to delete from the cursorOffset.
+ ImfEvent eventName; ///< The name of the event from the IMF.
+ int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
+ int numberOfChars; ///< number of characters to delete from the cursorOffset.
};
/**
/**
* @brief Constructor
*/
- ImfCallbackData( )
- : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
+ ImfCallbackData()
+ : currentText(),
+ cursorPosition( 0 ),
+ update( false ),
+ preeditResetRequired( false )
{
}
* @param[in] aCurrentText current text string
* @param[in] aPreeditResetRequired flag if preedit reset is required.
*/
- ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
- : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
+ ImfCallbackData( bool aUpdate, int aCursorPosition, const std::string& aCurrentText, bool aPreeditResetRequired )
+ : currentText( aCurrentText ),
+ cursorPosition( aCursorPosition ),
+ update( aUpdate ),
+ preeditResetRequired( aPreeditResetRequired )
{
}
- bool update; ///< if cursor position needs to be updated
- int cursorPosition; ///< new position of cursor
- std::string currentText; ///< current text string
- bool preeditResetRequired; ///< flag if preedit reset is required.
+ std::string currentText; ///< current text string
+ int cursorPosition; ///< new position of cursor
+ bool update :1; ///< if cursor position needs to be updated
+ bool preeditResetRequired :1; ///< flag if preedit reset is required.
};
typedef Signal< void (ImfManager&) > ImfManagerSignalType; ///< Keyboard actived signal
-
typedef Signal< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalType; ///< keyboard events
public:
static ImfManager Get();
/**
- * @brief Get the current imf context.
- * @return current imf context.
- */
- ImfContext GetContext();
-
- /**
* @brief Activate the IMF.
*
* It means that the text editing is started at somewhere.
*
* @return current position of cursor
*/
- int GetCursorPosition();
+ unsigned int GetCursorPosition() const;
/**
* @brief Method to store the string required by the IMF, this is used to provide predictive word suggestions.
*
* @param[in] text The text string surrounding the current cursor point.
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
* @brief Gets current text string set within the IMF manager, this is used to offer predictive suggestions.
*
* @return current position of cursor
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public:
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
{
}
-int ImfManager::GetCursorPosition()
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
{
- return mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>( cursorPosition );
}
-void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+unsigned int ImfManager::GetCursorPosition() const
{
- mIMFCursorPosition = ( int )cursorPosition;
+ return static_cast<unsigned int>( mIMFCursorPosition );
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
mSurroundingText = text;
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
return mSurroundingText;
}
void NotifyCursorPosition();
/**
- * @copydoc Dali::ImfManager::GetCursorPosition()
+ * @copydoc Dali::ImfManager::SetCursorPosition()
*/
- int GetCursorPosition();
+ void SetCursorPosition( unsigned int cursorPosition );
/**
- * @copydoc Dali::ImfManager::SetCursorPosition()
+ * @copydoc Dali::ImfManager::GetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition );
+ unsigned int GetCursorPosition() const;
/**
* @copydoc Dali::ImfManager::SetSurroundingText()
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
* @copydoc Dali::ImfManager::GetSurroundingText()
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public: // Signals
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
namespace
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
#endif
ImfManager::ImfManager( Ecore_X_Window ecoreXwin )
: mIMFContext(),
mIMFCursorPosition( 0 ),
- mSurroundingText(""),
+ mSurroundingText(),
mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false ),
- mKeyEvents()
+ mIdleCallbackConnected( false )
{
ecore_imf_init();
CreateContext( ecoreXwin );
* We are still predicting what the user is typing. The latest string is what the IMF module thinks
* the user wants to type.
*/
-void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info )
+void ImfManager::PreEditChanged( void*, Ecore_IMF_Context* imfContext, void* event_info )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
- char *preEditString( NULL );
+ char* preEditString( NULL );
int cursorPosition( 0 );
- Eina_List *attrs = NULL;
- Eina_List *l = NULL;
+ Eina_List* attrs = NULL;
+ Eina_List* l = NULL;
- Ecore_IMF_Preedit_Attr *attr;
+ 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.
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) ))
+ for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
{
#ifdef DALI_PROFILE_UBUNTU
if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
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' )
+ const char leadByte = preEditString[byteIndex];
+ while( leadByte != '\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.
+ const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
if ( byteIndex == attr->end_index )
{
cursorPosition = visualCharacterIndex;
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::ImfEventData imfEventData( Dali::ImfManager::PREEDIT, preEditString, cursorPosition, 0 );
Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
if ( callbackData.update )
free( preEditString );
}
-void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info )
+void ImfManager::CommitReceived( void*, Ecore_IMF_Context* imfContext, void* event_info )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
if ( Dali::Adaptor::IsAvailable() )
{
- const std::string keyString( (char *)event_info );
- const int cursorOffset( 0 );
- const int numberOfChars( 0 );
+ const std::string keyString( static_cast<char*>( event_info ) );
Dali::ImfManager handle( this );
- Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::COMMIT, keyString, 0, 0 );
Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
- if ( callbackData.update )
+ if( callbackData.update )
{
SetCursorPosition( callbackData.cursorPosition );
SetSurroundingText( callbackData.currentText );
* 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 )
+Eina_Bool ImfManager::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
- std::string keyString ( "" );
- int cursorOffset( 0 );
- int numberOfChars( 0 );
-
- Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
Dali::ImfManager handle( this );
mEventSignal.Emit( handle, imfData );
- if ( text )
+ if( text )
{
- std::string surroundingText( GetSurroundingText() );
-
- if ( !surroundingText.empty() )
- {
- *text = strdup( surroundingText.c_str() );
- }
- else
- {
- *text = strdup( "" );
- }
+ *text = strdup( mSurroundingText.c_str() );
}
- if ( cursorPosition )
+ if( cursorPosition )
{
- *cursorPosition = GetCursorPosition();
+ *cursorPosition = mIMFCursorPosition;
}
-
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 )
+void ImfManager::DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
- if ( Dali::Adaptor::IsAvailable() )
+ 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 );
+ Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
- Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::DELETESURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
Dali::ImfManager handle( this );
mEventSignal.Emit( handle, imfData );
}
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
- if ( mIMFContext )
+ if( mIMFContext )
{
ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
}
}
-int ImfManager::GetCursorPosition()
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
- return mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>( cursorPosition );
}
-void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+unsigned int ImfManager::GetCursorPosition() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
- mIMFCursorPosition = ( int )cursorPosition;
+ return static_cast<unsigned int>( mIMFCursorPosition );
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
mSurroundingText = text;
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
#include <Ecore_X.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/key-event-integ.h>
// INTERNAL INCLUDES
#include <imf-manager.h>
/**
* @copydoc Dali::ImfManager::PreEditChanged()
*/
- void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+ void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
/**
* @copydoc Dali::ImfManager::NotifyCursorPosition()
*/
- void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+ void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
/**
* @copydoc Dali::ImfManager::NotifyCursorPosition()
*/
- Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
+ Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
/**
* @copydoc Dali::ImfManager::DeleteSurrounding()
*/
- void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+ void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
// Cursor related
/**
void NotifyCursorPosition();
/**
- * @copydoc Dali::ImfManager::GetCursorPosition()
+ * @copydoc Dali::ImfManager::SetCursorPosition()
*/
- int GetCursorPosition();
+ void SetCursorPosition( unsigned int cursorPosition );
/**
- * @copydoc Dali::ImfManager::SetCursorPosition()
+ * @copydoc Dali::ImfManager::GetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition );
+ unsigned int GetCursorPosition() const;
/**
* @copydoc Dali::ImfManager::SetSurroundingText()
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
* @copydoc Dali::ImfManager::GetSurroundingText()
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public: // Signals
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
- std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
-
ImfManagerSignalType mActivatedSignal;
ImfEventSignalType mEventSignal;
#include <Ecore_X.h>
#include <algorithm>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
// Get Focus window
XGetInputFocus(display, &focusWindow, &revert);
- ecore_x_window_prop_property_set(focusWindow,
+ ecore_x_window_prop_property_set( focusWindow,
ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &angle, 1);
+ ECORE_X_ATOM_CARDINAL, 32, &angle, 1 );
XCloseDisplay(display);
}
}
void SetReturnKeyType( const InputMethod::ActionButton type )
{
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{