mirror of https://github.com/OpenTTD/OpenTTD
(svn r15387) -Codechange: Add a drop down list item type for char* strings.
parent
db54537369
commit
77760a62fd
|
@ -39,6 +39,16 @@ StringID DropDownListParamStringItem::String() const
|
||||||
return this->string;
|
return this->string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint DropDownListCharStringItem::Width() const
|
||||||
|
{
|
||||||
|
return GetStringBoundingBox(this->string).width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownListCharStringItem::Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const
|
||||||
|
{
|
||||||
|
DoDrawStringTruncated(this->string, x + 2, y, sel ? TC_WHITE : TC_BLACK, width);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all items of a drop down list and the list itself
|
* Delete all items of a drop down list and the list itself
|
||||||
* @param list List to delete.
|
* @param list List to delete.
|
||||||
|
|
|
@ -56,6 +56,21 @@ public:
|
||||||
virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; }
|
virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List item containing a C char string.
|
||||||
|
*/
|
||||||
|
class DropDownListCharStringItem : public DropDownListItem {
|
||||||
|
public:
|
||||||
|
const char *string;
|
||||||
|
|
||||||
|
DropDownListCharStringItem(const char *string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
|
||||||
|
virtual ~DropDownListCharStringItem() {}
|
||||||
|
|
||||||
|
virtual bool Selectable() const { return true; }
|
||||||
|
virtual uint Width() const;
|
||||||
|
virtual void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A drop down list is a collection of drop down list items.
|
* A drop down list is a collection of drop down list items.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue