Ejemplo n.º 1
0
	void toolbar_button::init()
	{
		if (iAction.is_checkable())
			set_checkable();
		label().set_placement(label_placement::ImageVertical);
		text().set_text(iAction.button_text());
		image().set_image(iAction.image());
		iSink += iAction.enabled([this]() { enable(); });
		iSink += iAction.disabled([this]() { disable(); });
		enable(iAction.is_enabled());
		auto update_checked = [this]()
		{
			if (is_checked())
			{
				iAction.check();
				image().set_image(iAction.checked_image());
			}
			else
			{
				iAction.uncheck();
				image().set_image(iAction.image());
			}
		};
		iSink += checked(update_checked);
		iSink += unchecked(update_checked);
		iSink += iAction.checked([this]() {set_checked(true); });
		iSink += iAction.unchecked([this]() {set_checked(false); });
		set_checked(iAction.is_checked());
	}
Ejemplo n.º 2
0
void AbstractButton::SetCheckable (bool checkable)
{
  if (!checkable) {
    set_checked(false);
  }

  set_checkable(checkable);
}
Ejemplo n.º 3
0
RadioButton::RadioButton ()
    : AbstractButton()
{
  set_round_type(RoundAll);
  set_checkable(true);

  Font font;	// default font
  int w = 80;
  int h = font.height();

  set_size(w + pixel_size(kPadding.hsum()),
           h + pixel_size(kPadding.vsum()));

  InitializeRadioButtonOnce();
}
Ejemplo n.º 4
0
RadioButton::RadioButton (const RefPtr<AbstractIcon>& icon)
    : AbstractButton(icon)
{
  set_round_type(RoundAll);
  set_checkable(true);

  int w = this->icon()->size().width();
  int h = this->icon()->size().height();

  w += pixel_size(kPadding.hsum());
  h += pixel_size(kPadding.vsum());

  set_size(w, h);

  InitializeRadioButtonOnce();
}
Ejemplo n.º 5
0
RadioButton::RadioButton (const String& text)
    : AbstractButton(text)
{
  set_round_type(RoundAll);
  set_checkable(true);

  int w = this->text()->size().width();
  int h = this->text()->font().height();
  if(w < 80) w = 80;

  w += pixel_size(kPadding.hsum());
  h += pixel_size(kPadding.vsum());

  set_size(w, h);

  InitializeRadioButtonOnce();
}
Ejemplo n.º 6
0
RadioButton::RadioButton (const RefPtr<AbstractIcon>& icon,
                          const String& text)
    : AbstractButton(icon, text)
{
  set_round_type(RoundAll);
  set_checkable(true);

  int w = this->icon()->size().width();
  int h = this->icon()->size().height();

  w += kIconTextSpace;

  w += this->text()->size().width();
  h = std::max(h, this->text()->font().height());

  if(w < 80) w = 80;
  w += pixel_size(kPadding.hsum());
  h += pixel_size(kPadding.vsum());

  set_size(w, h);

  InitializeRadioButtonOnce();
}