/** Creates a new instance of SmilePicker */
  public SmilePicker(Display display, MessageEdit me, int caretPos) {
    super(display);
    this.me = me;
    this.caretPos = caretPos;

    il = SmilesIcons.getInstance();
    // #ifdef SMILES
    // #         smileTable=MessageParser.getInstance().getSmileTable();
    // #endif
    imgCnt = smileTable.size();
    // il.getCount();

    imgWidth = il.getWidth() + 2 * CURSOR_HOFFSET;
    lineHeight = il.getHeight() + 2 * CURSOR_VOFFSET;

    xCnt = getWidth() / imgWidth;

    lines = imgCnt / xCnt;
    xLastCnt = imgCnt - lines * xCnt;
    if (xLastCnt > 0) lines++;
    else xLastCnt = xCnt;

    addCommand(cmdOK);
    addCommand(cmdBack);
    setCommandListener(this);
  }
 public void drawItem(Graphics g, int ofs, boolean selected, boolean drawsec) {
   int max = (lineIndex == lines - 1) ? xLastCnt : xCnt;
   for (int i = 0; i < max; i++) {
     il.drawImage(g, lineIndex * xCnt + i, i * imgWidth + CURSOR_HOFFSET, CURSOR_VOFFSET);
   }
 };