Exemple #1
0
void
KeyboardWidget::OnResize(const PixelRect &rc)
{
  PrepareSize(rc);
  ResizeButtons();
  MoveButtons(rc);
}
Exemple #2
0
void
KeyboardWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  PrepareSize(rc);

  TCHAR caption[] = _T(" ");

  for (const TCHAR *i = keyboard_letters; !StringIsEmpty(i); ++i) {
    caption[0] = *i;
    AddButton(parent, caption, *i);
  }

  AddButton(parent, _T("Space"), ' ');
  AddButton(parent, _T("."), '.');
  AddButton(parent, _T(","), ',');
  AddButton(parent, _T("-"), '-');

  if (show_shift_button) {
    WindowStyle style;
    style.Hide();
    shift_button.Create(parent, { 0, 0, 16, 16 }, style,
                        new SymbolButtonRenderer(look, _T("v")),
                        *this, SHIFT);
  }
  UpdateShiftState();
}
const char* cStringType::printf(const char *Str,...)
{
    PrepareSize(31);
    va_list vl;
	va_start(vl,Str);//инициализируем работу с переменным количеством параметров функции, после переменной FormatString
    int res=vsnprintf(TextBuffer,TextBufferSize,Str,vl);
    va_end(vl);//закончим работу с переменным количеством параметров функции
    if(res>=(int)TextBufferSize)
    {
        PrepareSize(res);
        va_start(vl,Str);//инициализируем работу с переменным количеством параметров функции, после переменной FormatString
        res=vsnprintf(TextBuffer,TextBufferSize,Str,vl);
        va_end(vl);//закончим работу с переменным количеством параметров функции
        TextBuffer[res]=0;
    }
    return TextBuffer;
}
const char *cStringType::operator +=(const char *Text)
{
    size_t L=strlen(Text)+strlen(TextBuffer?TextBuffer:"");
    PrepareSize(L);
    strncat(TextBuffer,Text,TextBufferSize);
    TextBuffer[TextBufferSize-1]=0;
    return TextBuffer;
}
const char* cStringType::add_printf(const char *Str,...)
{
    PrepareSize(TextBufferSize+31);
    va_list vl;
	va_start(vl,Str);//инициализируем работу с переменным количеством параметров функции, после переменной FormatString
	size_t len=GetLength();
    int res=vsnprintf(&TextBuffer[len],TextBufferSize-len,Str,vl);
    va_end(vl);//закончим работу с переменным количеством параметров функции
    if(res>=(int)(TextBufferSize-len))
    {
        PrepareSize(len+res);
        va_start(vl,Str);//инициализируем работу с переменным количеством параметров функции, после переменной FormatString
        res=vsnprintf(&TextBuffer[len],TextBufferSize-len,Str,vl);
        va_end(vl);//закончим работу с переменным количеством параметров функции
        TextBuffer[len+res]=0;
    }
    return TextBuffer;
}
bool cStringType::EatEOL()
{
    if(!TextBuffer)
        return false;

    size_t len=GetLength();
    if(len==0)
        return false;
    if(TextBuffer[len-1]=='\n')
    {
        PrepareSize();
        TextBuffer[len-1]='\0';
        return true;
    }else
        return false;
    return false;
}
cStringType::cStringType(size_t NewSize):TextBuffer(NULL),TextBufferSize(0)
{
    PrepareSize(NewSize);
}