mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[kandinsky] KDContext::drawString can take a max length
Change-Id: I59cf0c1fbfb2288ab54905a4fd2558885c279814
This commit is contained in:
@@ -16,7 +16,7 @@ public:
|
||||
|
||||
// Text
|
||||
void drawChar(char character, KDPoint p, KDText::FontSize size = KDText::FontSize::Large, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
|
||||
void drawString(const char * text, KDPoint p, KDText::FontSize size = KDText::FontSize::Large, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
|
||||
void drawString(const char * text, KDPoint p, KDText::FontSize size = KDText::FontSize::Large, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1);
|
||||
void blendChar(char character, KDPoint p, KDText::FontSize size, KDColor textColor = KDColorBlack);
|
||||
void blendString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor = KDColorBlack);
|
||||
|
||||
|
||||
@@ -27,11 +27,13 @@ void KDContext::drawChar(char character, KDPoint p, KDText::FontSize size, KDCol
|
||||
characterBuffer);
|
||||
}
|
||||
|
||||
void KDContext::drawString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor) {
|
||||
void KDContext::drawString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, int maxLength) {
|
||||
KDPoint position = p;
|
||||
int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH;
|
||||
KDPoint characterSize(characterWidth, 0);
|
||||
while(*text != 0) {
|
||||
|
||||
const char * end = text+maxLength;
|
||||
while(*text != 0 && text != end) {
|
||||
drawChar(*text, position, size, textColor, backgroundColor);
|
||||
text++;
|
||||
position = position.translatedBy(characterSize);
|
||||
|
||||
Reference in New Issue
Block a user