Ejemplo n.º 1
0
		// Добавляет линейку кнопок.
		void AddButtons(int ButtonCount, const int* MessageIDs, int defaultButtonIndex = 0, int cancelButtonIndex = -1)
		{
			int LineY = m_NextY++;
			T *PrevButton = nullptr;

			for (int i = 0; i < ButtonCount; i++)
			{
				T *NewButton = AddDialogItem(DI_BUTTON, GetLangString(MessageIDs[i]));
				NewButton->Flags = DIF_CENTERGROUP;
				NewButton->Y1 = NewButton->Y2 = LineY;
				if (PrevButton)
				{
					NewButton->X1 = PrevButton->X2 + 1;
				}
				else
				{
					NewButton->X1 = 2 + m_Indent;
					m_FirstButtonID = m_DialogItemsCount - 1;
				}
				NewButton->X2 = NewButton->X1 + ItemWidth(*NewButton);

				if (defaultButtonIndex == i)
				{
					NewButton->Flags |= DIF_DEFAULTBUTTON;
				}
				if (cancelButtonIndex == i)
					m_CancelButtonID = m_DialogItemsCount - 1;

				PrevButton = NewButton;
			}
		}
Ejemplo n.º 2
0
DialogItemEx *DialogBuilder::AddCheckbox(const wchar_t* Caption, BoolOption& Value)
{
	const auto Item = AddDialogItem(DI_CHECKBOX, Caption);
	SetNextY(Item);
	Item->X2 = Item->X1 + ItemWidth(*Item);
	Item->Selected = Value;
	SetLastItemBinding(CreateCheckBoxBinding(Value));
	return Item;
}
Ejemplo n.º 3
0
DialogItemEx *DialogBuilder::AddCheckbox(lng TextMessageId, Bool3Option& Value)
{
	const auto Item = AddDialogItem(DI_CHECKBOX, GetLangString(TextMessageId));
	Item->Flags |= DIF_3STATE;
	SetNextY(Item);
	Item->X2 = Item->X1 + ItemWidth(*Item);
	Item->Selected = Value;
	SetLastItemBinding(CreateCheckBoxBinding(Value));
	return Item;
}
Ejemplo n.º 4
0
		// Добавляет кнопку справа от элемента RelativeTo.
		T *AddButtonAfter(T *RelativeTo, int LabelId)
		{
			T *Item = AddDialogItem(DI_BUTTON, GetLangString(LabelId));
			Item->Y1 = Item->Y2 = RelativeTo->Y1;
			Item->X1 = RelativeTo->X1 + ItemWidth(*RelativeTo) - 1 + 2;

			DialogItemBinding<T> *Binding = FindBinding(RelativeTo);
			if (Binding)
				Binding->AfterLabelID = GetItemID(Item);

			return Item;
		}
Ejemplo n.º 5
0
		// Добавляет указанную текстовую строку справа от элемента RelativeTo.
		T *AddTextAfter(T *RelativeTo, const wchar_t* Label, int skip=1)
		{
			T *Item = AddDialogItem(DI_TEXT, Label);
			Item->Y1 = Item->Y2 = RelativeTo->Y1;
			Item->X1 = RelativeTo->X1 + ItemWidth(*RelativeTo) + skip;

			DialogItemBinding<T> *Binding = FindBinding(RelativeTo);
			if (Binding)
				Binding->AfterLabelID = GetItemID(Item);

			return Item;
		}
Ejemplo n.º 6
0
		// Добавляет чекбокс.
		T *AddCheckbox(int TextMessageId, int *Value, int Mask=0, bool ThreeState=false)
		{
			T *Item = AddDialogItem(DI_CHECKBOX, GetLangString(TextMessageId));
			if (ThreeState && !Mask)
				Item->Flags |= DIF_3STATE;
			SetNextY(Item);
			Item->X2 = Item->X1 + ItemWidth(*Item);
			if (!Mask)
				Item->Selected = *Value;
			else
				Item->Selected = (*Value & Mask) != 0;
			SetLastItemBinding(CreateCheckBoxBinding(Value, Mask));
			return Item;
		}
Ejemplo n.º 7
0
DialogItemEx *DialogBuilder::AddCheckbox(lng TextMessageId, IntOption& Value, int Mask, bool ThreeState)
{
	const auto Item = AddDialogItem(DI_CHECKBOX, GetLangString(TextMessageId));
	if (ThreeState && !Mask)
		Item->Flags |= DIF_3STATE;
	SetNextY(Item);
	Item->X2 = Item->X1 + ItemWidth(*Item);
	if (!Mask)
		Item->Selected = Value;
	else
		Item->Selected = (Value & Mask) != 0;
	SetLastItemBinding(CreateCheckBoxBinding(Value, Mask));
	return Item;
}
Ejemplo n.º 8
0
		// Завершает расположение полей диалога в две колонки.
		void EndColumns()
		{
			for(int i=m_ColumnStartIndex; i<m_DialogItemsCount; i++)
			{
				intptr_t Width = ItemWidth(m_DialogItems [i]);
				if (Width > m_ColumnMinWidth)
					m_ColumnMinWidth = Width;
				if (i >= m_ColumnBreakIndex)
				{
					m_DialogItems [i].X1 = SECOND_COLUMN;
					m_DialogItems [i].X2 = SECOND_COLUMN + Width;
				}
			}

			m_ColumnStartIndex = -1;
			m_ColumnBreakIndex = -1;
		}
Ejemplo n.º 9
0
		// Добавляет указанную текстовую строку слева от элемента RelativeTo.
		T *AddTextBefore(T *RelativeTo, int LabelId)
		{
			T *Item = AddDialogItem(DI_TEXT, GetLangString(LabelId));
			Item->Y1 = Item->Y2 = RelativeTo->Y1;
			Item->X1 = 5 + m_Indent;
			Item->X2 = Item->X1 + ItemWidth(*Item) - 1;

			intptr_t RelativeToWidth = RelativeTo->X2 - RelativeTo->X1;
			RelativeTo->X1 = Item->X2 + 2;
			RelativeTo->X2 = RelativeTo->X1 + RelativeToWidth;

			DialogItemBinding<T> *Binding = FindBinding(RelativeTo);
			if (Binding)
				Binding->BeforeLabelID = GetItemID(Item);

			return Item;
		}
Ejemplo n.º 10
0
		// Завершает расположение полей диалога в две колонки.
		void EndColumns()
		{
			for(int i=ColumnStartIndex; i<DialogItemsCount; i++)
			{
				int Width = ItemWidth(DialogItems [i]);
				if (Width > ColumnMinWidth)
					ColumnMinWidth = Width;
				if (i >= ColumnBreakIndex)
				{
					DialogItems [i].X1 = SECOND_COLUMN;
					DialogItems [i].X2 = SECOND_COLUMN + Width;
				}
			}

			ColumnStartIndex = -1;
			ColumnBreakIndex = -1;
		}
Ejemplo n.º 11
0
		// Добавляет группу радиокнопок.
		void AddRadioButtons(int *Value, int OptionCount, const int MessageIDs[], bool FocusOnSelected=false)
		{
			for(int i=0; i<OptionCount; i++)
			{
				T *Item = AddDialogItem(DI_RADIOBUTTON, GetLangString(MessageIDs[i]));
				SetNextY(Item);
				Item->X2 = Item->X1 + ItemWidth(*Item);
				if (!i)
					Item->Flags |= DIF_GROUP;
				if (*Value == i)
				{
					Item->Selected = TRUE;
					if (FocusOnSelected)
						Item->Flags |= DIF_FOCUS;
				}
				SetLastItemBinding(CreateRadioButtonBinding(Value));
			}
		}
Ejemplo n.º 12
0
		intptr_t MaxTextWidth()
		{
			intptr_t MaxWidth = 0;
			for(int i=1; i<m_DialogItemsCount; i++)
			{
				if (m_DialogItems [i].X1 == SECOND_COLUMN) continue;
				intptr_t Width = ItemWidth(m_DialogItems [i]);
				intptr_t Indent = m_DialogItems [i].X1 - 5;
				Width += Indent;

				if (MaxWidth < Width)
					MaxWidth = Width;
			}
			intptr_t ColumnsWidth = 2*m_ColumnMinWidth+1;
			if (MaxWidth < ColumnsWidth)
				return ColumnsWidth;
			return MaxWidth;
		}