| 1 /* |
1 /* |
| 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
| 3 * |
3 * |
| 4 * Copyright 2015 Olaf Wintermann. All rights reserved. |
4 * Copyright 2025 Olaf Wintermann. All rights reserved. |
| 5 * |
5 * |
| 6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
| 8 * |
8 * |
| 9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
| 27 */ |
27 */ |
| 28 |
28 |
| 29 #include "label.h" |
29 #include "label.h" |
| 30 #include "container.h" |
30 #include "container.h" |
| 31 #include "toolkit.h" |
31 #include "toolkit.h" |
| |
32 #include "ui/display.h" |
| 32 |
33 |
| 33 UIWIDGET ui_label(UiObject *obj, char *label) { |
34 |
| 34 QString str = QString::fromUtf8(label); |
35 UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs args) { |
| |
36 UiContainerPrivate *ctn = ui_obj_container(obj); |
| |
37 UI_APPLY_LAYOUT(ctn->layout, args); |
| |
38 |
| |
39 QString str = QString::fromUtf8(args.label); |
| 35 QLabel *widget = new QLabel(str); |
40 QLabel *widget = new QLabel(str); |
| 36 |
41 |
| 37 UiContainer *ct = uic_get_current_container(obj); |
42 Qt::AlignmentFlag align = Qt::AlignCenter; |
| 38 ct->add(widget, false); |
43 if(args.align == UI_ALIGN_LEFT) { |
| |
44 align = Qt::AlignLeft; |
| |
45 } else if(args.align == UI_ALIGN_RIGHT) { |
| |
46 align = Qt::AlignRight; |
| |
47 } |
| |
48 widget->setAlignment(align); |
| |
49 |
| |
50 ctn->add(widget, false); |
| 39 |
51 |
| 40 return widget; |
52 return widget; |
| 41 } |
53 } |
| 42 |
54 |
| 43 UIWIDGET ui_space(UiObject *obj) { |
55 UIWIDGET ui_llabel_create(UiObject* obj, UiLabelArgs args) { |
| 44 // TODO: maybe there is a better widget for this purpose |
56 args.align = UI_ALIGN_LEFT; |
| 45 QLabel *widget = new QLabel(); |
57 return ui_label_create(obj, args); |
| 46 |
|
| 47 UiContainer *ct = uic_get_current_container(obj); |
|
| 48 ct->add(widget, true); |
|
| 49 |
|
| 50 return widget; |
|
| 51 } |
58 } |
| |
59 |
| |
60 UIWIDGET ui_rlabel_create(UiObject* obj, UiLabelArgs args) { |
| |
61 args.align = UI_ALIGN_RIGHT; |
| |
62 return ui_label_create(obj, args); |
| |
63 } |