/* 
 * © 2008-2009 Sun Microsystems, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#include "stdafx.h"

#include <mforms/textbox.h>
#include <mforms/mforms.h>

using namespace mforms;

TextBox::TextBox(ScrollBars scroll_bars)
  : _updating(false)
{
  _textbox_impl= &ControlFactory::get_instance()->_textbox_impl;

  _textbox_impl->create(this, scroll_bars);
}


void TextBox::set_value(const std::string &text)
{
  _updating= true;
  _textbox_impl->set_text(this, text);
  _updating= false;
}


void TextBox::append_text(const std::string &text)
{
  _textbox_impl->append_text(this, text);
}


void TextBox::set_bordered(bool flag)
{
  _textbox_impl->set_bordered(this, flag);
}


void TextBox::set_read_only(bool flag)
{
  _textbox_impl->set_read_only(this, flag);
}

void TextBox::set_padding(int pad)
{
  _textbox_impl->set_padding(this, pad);
}


std::string TextBox::get_string_value()
{
  return _textbox_impl->get_text(this);
}


void TextBox::callback()
{
  if (!_updating)
    _signal_changed.emit();
}


