I've put all the dividend window stuff below to try and show as much as I can, I hope it's not too much but I was unsure what would be needed.
Code: Select all
struct SetDividendWindow : Window {
SetDividendWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->InitNested(window_number);
this->owner = (Owner)this->window_number;
}
virtual void SetStringParameters(int widget) const
{
switch (widget) {
case WID_CD_CAPTION:
SetDParam(0, (CompanyID)this->window_number);
break;
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch(widget)
{
case WID_CD_TYPE_DESC:
size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_DIVIDEND_VIEW_TYPE).width);
break;
}
}
virtual void DrawWidget(const Rect &r, int widget) const
{
switch(widget)
{
case WID_CD_TYPE_DESC:
DrawString(r.left, r.right, r.top, STR_COMPANY_DIVIDEND_VIEW_TYPE);
break;
}
}
};
static const NWidgetPart _nested_dividends_widgets[] = {
/** START CAPTION BOX */
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_CD_CAPTION), SetDataTip(STR_COMPANY_DIVIDEND_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
/* END CAPTION BOX */
/* START DIVIDEND BOX */
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(NWID_VERTICAL), SetPIP(8, 8, 8),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXT, COLOUR_WHITE, WID_CD_TYPE_DESC),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_CD_TYPE_L), SetDataTip(AWV_DECREASE, STR_FACE_HAIR_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CD_TYPE), SetDataTip(STR_EMPTY, STR_FACE_HAIR_TOOLTIP),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_CD_TYPE_R), SetDataTip(AWV_INCREASE, STR_FACE_HAIR_TOOLTIP),
EndContainer(),
EndContainer(),
EndContainer(),
/* END DIVIDEND BOX */
};
static WindowDesc _set_company_dividend_desc(
WDP_AUTO, NULL, 0, 0,
WC_SET_DIVIDENDS, WC_NONE,
WDF_CONSTRUCTION,
_nested_dividends_widgets, lengthof(_nested_dividends_widgets)
);
The reason I need to do it via the draw event is that the user will be able to select "%" or "value" as the first options and so the second question should reflect the first selections choice.
If anyone can point me in the right direction I would be really grateful.
Many Thanks,
Ben