//-------------------------------------------------------------- // paint content of control void mgSimpleField::paint( mgContext* gc) { // select frame based on state const mgFrame* frame = NULL; mgColor textColor; getFrame(frame, textColor); mgSurface* surface = getSurface(); gc->setFont(m_font); gc->setAlphaMode(MG_ALPHA_SET); // draw the background mgDimension size; getSize(size); mgRectangle inside(0, 0, size.m_width, size.m_height); if (frame != NULL) { frame->paintBackground(gc, 0, 0, size.m_width, size.m_height); frame->getInsideRect(inside); } // shouldn't happen, but make sure cursor not off left edge m_scrollPosn = min(m_scrollPosn, m_cursorPosn); // get visible portion of text mgString displayText(m_text); displayText.deleteAt(0, m_scrollPosn); int displayLen = m_font->stringFit(displayText, displayText.length(), size.m_width); int ascent = m_font->getAscent(); int lineHeight = m_font->getHeight(); int y = (inside.m_height - lineHeight)/2; // mgRectangle bounds; // mgPoint endPt; // m_overlay->stringExtent(displayText, displayLen, endPt, bounds); gc->setAlphaMode(MG_ALPHA_MERGE); gc->setTextColor(textColor); gc->drawString(displayText, displayLen, inside.m_x, inside.m_y+y+ascent); if (isKeyFocus()) { // draw the cursor int cursorX = getCursorX(displayText); // gc->setAlphaMode(MG_ALPHA_SET); // gc->setAlpha(255); gc->setBrush(surface->createBrush(textColor)); if (m_insertMode) { // draw cursor, 2-pixel wide line gc->fillRect(inside.m_x+cursorX, inside.m_y+y, 2, lineHeight); } else { // draw block cursor char underCursor[MG_MAX_LETTER]; displayText.nextLetter(m_cursorPosn - m_scrollPosn, underCursor); int cursorWidth = m_font->stringWidth(underCursor, (int) strlen(underCursor)); gc->drawRect(inside.m_x+cursorX, inside.m_y+y, cursorWidth, lineHeight); } } if (frame != NULL) frame->paintForeground(gc, 0, 0, size.m_width, size.m_height); }
sp<ANativeWindow> android_Surface_getNativeWindow( JNIEnv* env, jobject clazz) { return getSurface(env, clazz); }
SDLImageManaged::~SDLImageManaged() { resMgr.Drop(getSurface()); }