Exemple #1
0
TBEditField::TBEditField()
	: m_edit_type(EDIT_TYPE_TEXT)
	, m_adapt_to_content_size(false)
	, m_virtual_width(250)
{
	SetIsFocusable(true);
	SetWantLongClick(true);
	AddChild(&m_scrollbar_x);
	AddChild(&m_scrollbar_y);
	AddChild(&m_root);
	m_root.SetGravity(WIDGET_GRAVITY_ALL);
	m_scrollbar_x.SetGravity(WIDGET_GRAVITY_BOTTOM | WIDGET_GRAVITY_LEFT_RIGHT);
	m_scrollbar_y.SetGravity(WIDGET_GRAVITY_RIGHT | WIDGET_GRAVITY_TOP_BOTTOM);
	m_scrollbar_y.SetAxis(AXIS_Y);
	int scrollbar_y_w = m_scrollbar_y.GetPreferredSize().pref_w;
	int scrollbar_x_h = m_scrollbar_x.GetPreferredSize().pref_h;
	m_scrollbar_x.SetRect(TBRect(0, - scrollbar_x_h, - scrollbar_y_w, scrollbar_x_h));
	m_scrollbar_y.SetRect(TBRect(- scrollbar_y_w, 0, scrollbar_y_w, 0));
	m_scrollbar_x.SetOpacity(0);
	m_scrollbar_y.SetOpacity(0);

	SetSkinBg(TBIDC("TBEditField"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	m_style_edit.SetListener(this);

	m_root.SetRect(GetVisibleRect());

	m_placeholder.SetTextAlign(TB_TEXT_ALIGN_LEFT);

	m_content_factory.editfield = this;
	m_style_edit.SetContentFactory(&m_content_factory);
}
TBInlineSelect::TBInlineSelect()
    : m_value(0)
    , m_min(0)
    , m_max(100)
    , m_modified(false)
{
    SetSkinBg(TBIDC("TBInlineSelect"));
    AddChild(&m_layout);
    m_layout.AddChild(&m_buttons[0]);
    m_layout.AddChild(&m_editfield);
    m_layout.AddChild(&m_buttons[1]);
    m_layout.SetRect(GetPaddingRect());
    m_layout.SetGravity(WIDGET_GRAVITY_ALL);
    m_layout.SetSpacing(0);
    m_buttons[0].SetSkinBg(TBIDC("TBButton.flat"));
    m_buttons[1].SetSkinBg(TBIDC("TBButton.flat"));
    m_buttons[0].GetContentRoot()->AddChild(new TBSkinImage(TBIDC("arrowdark.left")));
    m_buttons[1].GetContentRoot()->AddChild(new TBSkinImage(TBIDC("arrowdark.right")));
    m_buttons[0].SetIsFocusable(false);
    m_buttons[1].SetIsFocusable(false);
    m_buttons[0].SetID(TBIDC("dec"));
    m_buttons[1].SetID(TBIDC("inc"));
    m_buttons[0].SetAutoRepeat(true);
    m_buttons[1].SetAutoRepeat(true);
    m_editfield.SetID(TBIDC("edit"));
    m_editfield.SetTextAlign(TB_TEXT_ALIGN_CENTER);
    m_editfield.SetEditType(EDIT_TYPE_NUMBER);
    m_editfield.SetText("0");

    m_editfield.AddListener(this);

}
TBProgressSpinner::TBProgressSpinner()
	: m_value(0)
	, m_frame(0)
{
	SetSkinBg(TBIDC("TBProgressSpinner"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	m_skin_fg.Set(TBIDC("TBProgressSpinner.fg"));
}
TBSimpleLayoutItemWidget::TBSimpleLayoutItemWidget(TBID image, TBSelectItemSource *source, const char *str)
	: m_source(source)
	, m_menu(nullptr)
{
	SetSkinBg(TBIDC("TBSelectItem"));
	SetLayoutDistribution(LAYOUT_DISTRIBUTION_AVAILABLE);
	SetPaintOverflowFadeout(false);

	if (image)
	{
		m_image.SetSkinBg(image);
		m_image.SetIgnoreInput(true);
		AddChild(&m_image);
	}

	m_textfield.SetText(str);
	m_textfield.SetTextAlign(TB_TEXT_ALIGN_LEFT);
	m_textfield.SetIgnoreInput(true);
	AddChild(&m_textfield);

	if (source)
	{
		m_image_arrow.SetSkinBg(TBIDC("arrow.right"));
		m_image_arrow.SetIgnoreInput(true);
		AddChild(&m_image_arrow);
	}
}
TBPopupWindow::TBPopupWindow(TBWidget *target)
    : m_target(target)
{
    TBWidgetListener::AddGlobalListener(this);
    SetSkinBg(TBIDC("TBPopupWindow"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    SetSettings(WINDOW_SETTINGS_NONE);
}
void TBSlider::SetAxis(AXIS axis)
{
	if (axis == m_axis)
		return;
	m_axis = axis;
	if (axis == AXIS_X)
	{
		SetSkinBg(TBIDC("TBSliderBgX"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
		m_handle.SetSkinBg(TBIDC("TBSliderFgX"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	}
	else
	{
		SetSkinBg(TBIDC("TBSliderBgY"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
		m_handle.SetSkinBg(TBIDC("TBSliderFgY"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	}
	Invalidate();
}
Exemple #7
0
TBSelectDropdown::TBSelectDropdown()
    : m_value(-1)
{
    SetSource(&m_default_source);
    SetSkinBg(TBIDC("TBSelectDropdown"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    m_arrow.SetSkinBg(TBIDC("TBSelectDropdown.arrow"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    GetContentRoot()->AddChild(&m_arrow);
}
TBMenuWindow::TBMenuWindow(TBWidget *target, TBID id)
	: TBPopupWindow(target)
{
	SetID(id);
	SetSkinBg(TBIDC("TBMenuWindow"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	m_select_list.GetScrollContainer()->SetAdaptToContentSize(true);
	m_select_list.SetIsFocusable(false); ///< Avoid it autoclosing its window on click
	m_select_list.SetSkinBg("");
	m_select_list.SetRect(GetPaddingRect());
	m_select_list.SetGravity(WIDGET_GRAVITY_ALL);
	AddChild(&m_select_list);
}
Exemple #9
0
TBWindow::TBWindow()
	: m_settings(WINDOW_SETTINGS_DEFAULT)
{
	SetSkinBg(TBIDC("TBWindow"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	AddChild(&m_mover);
	AddChild(&m_resizer);
	m_mover.SetSkinBg(TBIDC("TBWindow.mover"));
	m_mover.AddChild(&m_textfield);
	m_textfield.SetIgnoreInput(true);
	m_mover.AddChild(&m_close_button);
	m_close_button.SetSkinBg(TBIDC("TBWindow.close"));
	m_close_button.SetIsFocusable(false);
	m_close_button.SetID(TBIDC("TBWindow.close"));
	SetIsGroupRoot(true);
}
TBButton::TBButton()
	: m_auto_repeat_click(false)
	, m_toggle_mode(false)
{
	SetIsFocusable(true);
	SetClickByKey(true);
	SetSkinBg(TBIDC("TBButton"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	AddChild(&m_layout);
	// Set the textfield gravity to all, even though it would display the same with default gravity.
	// This will make the buttons layout expand if there is space available, without forcing the parent
	// layout to grow to make the space available.
	m_textfield.SetGravity(WIDGET_GRAVITY_ALL);
	m_layout.AddChild(&m_textfield);
	m_layout.SetRect(GetPaddingRect());
	m_layout.SetGravity(WIDGET_GRAVITY_ALL);
	m_layout.SetPaintOverflowFadeout(false);
}
Exemple #11
0
AdvancedItemWidget::AdvancedItemWidget(AdvancedItem *item, AdvancedItemSource *source,
										TBSelectItemViewer *source_viewer, int index)
	: m_source(source)
	, m_source_viewer(source_viewer)
	, m_index(index)
{
	SetSkinBg(TBIDC("TBSelectItem"));
	SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
	SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
	SetPaintOverflowFadeout(false);

	g_widgets_reader->LoadFile(GetContentRoot(), "Demo/demo01/ui_resources/test_list_item.tb.txt");
	TBCheckBox *checkbox = GetWidgetByIDAndType<TBCheckBox>(TBIDC("check"));
	TBTextField *name = GetWidgetByIDAndType<TBTextField>(TBIDC("name"));
	TBTextField *info = GetWidgetByIDAndType<TBTextField>(TBIDC("info"));
	checkbox->SetValue(item->GetChecked() ? true : false);
	name->SetText(item->str);
	info->SetText(item->GetMale() ? "Male" : "Female");
}
MenubarItemWidget::MenubarItemWidget(MenubarItem *item, MenubarItemSource *source,
                                     TBSelectItemViewer *source_viewer, int index)
    : m_source(source)
    , m_source_viewer(source_viewer)
    , m_index(index)
{
    SetSkinBg(TBIDC("TBSelectItem"));
    SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
    SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    SetPaintOverflowFadeout(false);

    TBWidget* root = GetContentRoot();

    TBFontDescription fd;
    fd.SetID(TBIDC("Vera"));
    fd.SetSize(12);

    TBTextField* text = new TBTextField();
    text->SetIgnoreInput(true);
    text->SetText(item->str);
    text->SetFontDescription(fd);
    root->AddChild(text);

    if (item->shortcut_.Length())
    {
        TBWidget* spacer = new TBWidget();
        spacer->SetIgnoreInput(true);
        spacer->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
        root->AddChild(spacer);

        TBTextField* shortcut = new TBTextField();
        shortcut->SetIgnoreInput(true);
        shortcut->SetText(item->shortcut_.CString());
        shortcut->SetFontDescription(fd);
        shortcut->SetGravity(WIDGET_GRAVITY_RIGHT);
        root->AddChild(shortcut);
    }

}
Exemple #13
0
TBSelectList::TBSelectList()
    : m_value(-1)
    , m_list_is_invalid(false)
    , m_scroll_to_current(false)
    , m_header_lng_string_id(TBIDC("TBList.header"))
{
    SetSource(&m_default_source);
    SetIsFocusable(true);
    SetSkinBg(TBIDC("TBSelectList"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    m_container.SetGravity(WIDGET_GRAVITY_ALL);
    m_container.SetRect(GetPaddingRect());
    AddChild(&m_container);
    m_layout.SetGravity(WIDGET_GRAVITY_ALL);
    m_layout.SetAxis(AXIS_Y);
    m_layout.SetSpacing(0);
    m_layout.SetLayoutPosition(LAYOUT_POSITION_LEFT_TOP);
    m_layout.SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    m_layout.SetLayoutSize(LAYOUT_SIZE_AVAILABLE);
    m_container.GetContentRoot()->AddChild(&m_layout);
    m_container.SetScrollMode(SCROLL_MODE_Y_AUTO);
    m_container.SetAdaptContentSize(true);
}
TBSeparator::TBSeparator()
{
	SetSkinBg(TBIDC("TBSeparator"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	SetState(WIDGET_STATE_DISABLED, true);
}
TBDimmer::TBDimmer()
{
	SetSkinBg(TBIDC("TBDimmer"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
	SetGravity(WIDGET_GRAVITY_ALL);
}
TBTextField::TBTextField()
	: m_cached_text_width(UPDATE_TEXT_WIDTH_CACHE)
	, m_squeezable(false)
{
	SetSkinBg(TBIDC("TBTextField"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
}
TBResizer::TBResizer()
{
	SetSkinBg(TBIDC("TBResizer"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
}
TBContainer::TBContainer()
{
	SetSkinBg(TBIDC("TBContainer"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
}
ListViewItemWidget::ListViewItemWidget(ListViewItem *item, ListViewItemSource *source,
                                       TBSelectItemViewer *sourceviewer, int index)
    : source_(source)
    , sourceviewer_(sourceviewer)
    , index_(index)
    , item_(item)
    , expandBox_(0)
    , textField_(0)
    , icon_(0)
{
    SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
    SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    SetPaintOverflowFadeout(false);

    item_->widget_ = this;

    for (int i = 0; i < item->depth_; i++)
    {
        LayoutParams lp;
        lp.SetWidth(6);
        lp.SetHeight(4);
        TBWidget* spacer = new TBWidget();
        spacer->SetLayoutParams(lp);
        GetContentRoot()->AddChild(spacer);
    }

    if (item_->children_.Size())
    {
        expandBox_ = new TBCheckBox();
        expandBox_->SetSkinBg(TBIDC("TBCheckBox.uilistview"));
        expandBox_->SetValue(item_->GetExpanded());
        expandBox_->SetID(item->id);
        GetContentRoot()->AddChild(expandBox_);
    }
    else
    {
        LayoutParams lp;
        lp.SetWidth(12);
        lp.SetHeight(4);
        TBWidget* spacer = new TBWidget();
        spacer->SetLayoutParams(lp);
        GetContentRoot()->AddChild(spacer);
    }

    if (item->icon_.Length())
    {
        icon_ = new TBSkinImage(TBIDC(item->icon_.CString()));
        icon_->SetIgnoreInput(true);
        GetContentRoot()->AddChild(icon_);
    }

    TBFontDescription fd;
    fd.SetID(TBIDC("Vera"));
    fd.SetSize(11);

    TBTextField* tfield = textField_ = new TBTextField();
    tfield->SetIgnoreInput(true);

    tfield->SetSkinBg(item->textSkin_.Length() ? TBIDC(item->textSkin_.CString()) : TBIDC("Folder"));
    tfield->SetText(item->str);
    tfield->SetFontDescription(fd);

    SetSkinBg(TBIDC("TBSelectItem"));
    GetContentRoot()->AddChild(tfield);

    SetID(item->id);
}