diff options
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r-- | src/ui/labelwidget.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 3bfa600b..b84e17f4 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -44,11 +44,13 @@ struct Impl_LabelWidget { | |||
44 | iString command; | 44 | iString command; |
45 | iClick click; | 45 | iClick click; |
46 | struct { | 46 | struct { |
47 | uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ | 47 | uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ |
48 | uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ | 48 | uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ |
49 | uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ | 49 | uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ |
50 | uint8_t noTopFrame : 1; | 50 | uint8_t noTopFrame : 1; |
51 | uint8_t wrap : 1; | 51 | uint8_t wrap : 1; |
52 | uint8_t allCaps : 1; | ||
53 | uint8_t removeTrailingColon : 1; | ||
52 | } flags; | 54 | } flags; |
53 | }; | 55 | }; |
54 | 56 | ||
@@ -442,11 +444,18 @@ void updateSize_LabelWidget(iLabelWidget *d) { | |||
442 | 444 | ||
443 | static void replaceVariables_LabelWidget_(iLabelWidget *d) { | 445 | static void replaceVariables_LabelWidget_(iLabelWidget *d) { |
444 | translate_Lang(&d->label); | 446 | translate_Lang(&d->label); |
447 | if (d->flags.allCaps) { | ||
448 | set_String(&d->label, collect_String(upper_String(&d->label))); | ||
449 | } | ||
450 | if (d->flags.removeTrailingColon && endsWith_String(&d->label, ":")) { | ||
451 | removeEnd_String(&d->label, 1); | ||
452 | } | ||
445 | } | 453 | } |
446 | 454 | ||
447 | void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | 455 | void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { |
448 | iWidget *w = &d->widget; | 456 | iWidget *w = &d->widget; |
449 | init_Widget(w); | 457 | init_Widget(w); |
458 | iZap(d->flags); | ||
450 | d->font = uiLabel_FontId; | 459 | d->font = uiLabel_FontId; |
451 | d->forceFg = none_ColorId; | 460 | d->forceFg = none_ColorId; |
452 | d->icon = 0; | 461 | d->icon = 0; |
@@ -464,11 +473,6 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | |||
464 | d->kmods = 0; | 473 | d->kmods = 0; |
465 | init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); | 474 | init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); |
466 | setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); | 475 | setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); |
467 | d->flags.alignVisual = iFalse; | ||
468 | d->flags.noAutoMinHeight = iFalse; | ||
469 | d->flags.drawAsOutline = iFalse; | ||
470 | d->flags.noTopFrame = iFalse; | ||
471 | d->flags.wrap = iFalse; | ||
472 | updateSize_LabelWidget(d); | 476 | updateSize_LabelWidget(d); |
473 | updateKey_LabelWidget_(d); /* could be bound to another key */ | 477 | updateKey_LabelWidget_(d); /* could be bound to another key */ |
474 | } | 478 | } |
@@ -525,6 +529,20 @@ void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { | |||
525 | } | 529 | } |
526 | } | 530 | } |
527 | 531 | ||
532 | void setAllCaps_LabelWidget(iLabelWidget *d, iBool allCaps) { | ||
533 | if (d) { | ||
534 | d->flags.allCaps = allCaps; | ||
535 | replaceVariables_LabelWidget_(d); | ||
536 | } | ||
537 | } | ||
538 | |||
539 | void setRemoveTrailingColon_LabelWidget(iLabelWidget *d, iBool removeTrailingColon) { | ||
540 | if (d) { | ||
541 | d->flags.removeTrailingColon = removeTrailingColon; | ||
542 | replaceVariables_LabelWidget_(d); | ||
543 | } | ||
544 | } | ||
545 | |||
528 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { | 546 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { |
529 | set_String(&d->label, text); | 547 | set_String(&d->label, text); |
530 | set_String(&d->srcLabel, text); | 548 | set_String(&d->srcLabel, text); |