+ void GetClosestCursorPosition( float& x, float& y, float& height )
+ {
+ // TODO - Look at LineRuns first
+
+ Text::Length numberOfGlyphs = mVisualModel->GetNumberOfGlyphs();
+ if( 0 == numberOfGlyphs )
+ {
+ return;
+ }
+
+ Vector<GlyphInfo> glyphs;
+ glyphs.Resize( numberOfGlyphs );
+ mVisualModel->GetGlyphs( &glyphs[0], 0, numberOfGlyphs );
+
+ std::vector<Vector2> positions;
+ positions.resize( numberOfGlyphs );
+ mVisualModel->GetGlyphPositions( &positions[0], 0, numberOfGlyphs );
+
+ unsigned int closestGlyph = 0;
+ float closestDistance = std::numeric_limits<float>::max();
+
+ for( unsigned int i=0; i<glyphs.Count(); ++i )
+ {
+ float glyphX = positions[i].x + glyphs[i].width*0.5f;
+ float glyphY = positions[i].y + glyphs[i].height*0.5f;
+
+ float distanceToGlyph = fabsf( glyphX - x ) + fabsf( glyphY - y );
+
+ if( distanceToGlyph < closestDistance )
+ {
+ closestDistance = distanceToGlyph;
+ closestGlyph = i;
+ }
+ }
+
+ // TODO - Consider RTL languages
+ x = positions[closestGlyph].x + glyphs[closestGlyph].width;
+ y = 0.0f;
+
+ FontMetrics metrics;
+ TextAbstraction::FontClient::Get().GetFontMetrics( glyphs[closestGlyph].fontId, metrics );
+ height = metrics.height; // TODO - Fix for multi-line
+ }
+
+ LogicalModelPtr mLogicalModel;
+ VisualModelPtr mVisualModel;
+ DecoratorPtr mDecorator;