1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/*
* just displays a text, will be auto-translated
*
* Copyright (c) 1997 - 2001 Hansjrg Malthaner
*
* This file is part of the Simutrans project under the artistic licence.
*/
#include <stdio.h>
#include <string.h>
#include "../../simdebug.h"
#include "gui_label.h"
#include "../../simgraph.h"
#include "../../simcolor.h"
#include "../../dataobj/translator.h"
#include "../../utils/simstring.h"
gui_label_t::gui_label_t(const char* text, int color_, align_t align_) :
align(align_),
color(color_)
{
setze_text( text );
}
/**
* setzt den Text des Labels
* @author Hansjrg Malthaner
*/
void gui_label_t::setze_text(const char *text)
{
this->text = translator::translate(text);
}
/**
* Zeichnet die Komponente
* @author Hj. Malthaner
*/
void gui_label_t::zeichnen(koord offset)
{
if(align == money) {
if(text) {
const char *separator = strrchr(text, get_fraction_sep());
if(separator) {
display_proportional_clip(pos.x+offset.x, pos.y+offset.y, translator::translate(separator), ALIGN_LEFT, color, true);
*const_cast<char *>(separator) = '\0';
display_proportional_clip(pos.x+offset.x, pos.y+offset.y, translator::translate(text), ALIGN_RIGHT, color, true);
*const_cast<char *>(separator) = ',';
} else {
display_proportional_clip(pos.x+offset.x, pos.y+offset.y, text, ALIGN_RIGHT, color, true);
}
}
}
else if(text) {
int al;
switch(align) {
case left:
al = ALIGN_LEFT;
break;
case centered:
al = ALIGN_MIDDLE;
break;
case right:
al = ALIGN_RIGHT;
break;
default:
al = ALIGN_LEFT;
}
display_proportional_clip(pos.x+offset.x, pos.y+offset.y, text, al, color, true);
}
}
|