Ejemplo n.º 1
0
PixelSize
Font::TextSize(const TCHAR *text) const
{
    AnyCanvas canvas;
    canvas.select(*this);
    return canvas.text_size(text);
}
Ejemplo n.º 2
0
void PopupMessage::Resize() {
  PixelRect rthis;

  if (*msgText == _T('\0')) {
    hide();
  } else {
    set_text(msgText);

    AnyCanvas canvas;
    canvas.select(Fonts::MapBold);
    PixelSize tsize = canvas.text_size(msgText);

    int linecount = max((unsigned)nvisible, max((unsigned)1, get_row_count()));

    int width =// min((rc.right-rc.left)*0.8,tsize.cx);
      (int)((rc.right-rc.left)*0.9);
    int height = min((int)((rc.bottom-rc.top) * 0.8),
                     (int)tsize.cy * (linecount + 1));
    int h1 = height/2;
    int h2 = height-h1;

    int midx = (rc.right+rc.left)/2;
    int midy = (rc.bottom+rc.top)/2;

    if (Appearance.StateMessageAlign == smAlignTopLeft){
      rthis.top = 0;
      rthis.left = 0;
      rthis.bottom = height;
      rthis.right = Layout::FastScale(206);
      // TODO code: this shouldn't be hard-coded
    } else {
      rthis.left = midx-width/2;
      rthis.right = midx+width/2;
      rthis.top = midy-h1;
      rthis.bottom = midy+h2;
    }

    move(rthis.left, rthis.top,
         rthis.right - rthis.left,
         rthis.bottom - rthis.top);
    show_on_top();
  }

}