still implemeting uitextedit

This commit is contained in:
Eduardo Bart
2011-04-15 19:07:23 -03:00
parent 43c9c5de7c
commit 5bfeee91b2
5 changed files with 27 additions and 2 deletions

View File

@@ -81,6 +81,7 @@ public:
const Size *getGlyphsSize() const { return m_glyphsSize; }
const TexturePtr& getTexture() const { return m_texture; }
int getTopMargin() const { return m_topMargin; }
const Size& getGlyphSpacing() const { return m_glyphSpacing; }
private:
void calculateGlyphsWidthsAutomatically(const Size& glyphSize);

View File

@@ -281,4 +281,17 @@ void TextArea::moveCursor(bool right)
recalculate();
}
int TextArea::getTextPos(Point pos)
{
int textLength = m_text.length();
dump << " get pos: " << pos << m_drawArea;
for(int i=0;i<textLength;++i) {
Rect clickGlyphRect = m_glyphsCoords[i];
clickGlyphRect.addTop(m_font->getTopMargin() + m_font->getGlyphSpacing().height());
clickGlyphRect.addLeft(m_font->getGlyphSpacing().width()+1);
dump << clickGlyphRect;
if(m_glyphsCoords[i].contains(pos))
return i;
}
return -1;
}

View File

@@ -54,6 +54,8 @@ public:
const std::string& getText() const { return m_text; }
int getTextPos(Point pos);
private:
void recalculate();