ui/motif/label.c

branch
newapi
changeset 428
c7dcd2ab2d3d
parent 406
0ebf9d7b23e8
child 429
0921f8a5d535
equal deleted inserted replaced
427:7ead63398a50 428:c7dcd2ab2d3d
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 2014 Olaf Wintermann. All rights reserved. 4 * Copyright 2024 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
32 #include "label.h" 32 #include "label.h"
33 #include "container.h" 33 #include "container.h"
34 #include "../common/context.h" 34 #include "../common/context.h"
35 #include "../common/object.h" 35 #include "../common/object.h"
36 36
37 static UIWIDGET label_create(UiObject *obj, UiLabelArgs args, int align) {
38 Arg xargs[16];
39 int n = 0;
40
41 UiContainerPrivate *ctn = ui_obj_container(obj);
42 UI_APPLY_LAYOUT(ctn->layout, args);
43
44 Widget parent = ctn->prepare(ctn, xargs, &n);
45
46 XtSetArg(xargs[n], XmNalignment, align); n++;
47 XmString label = NULL;
48 if(args.label) {
49 label = XmStringCreateLocalized((char*)args.label);
50 XtSetArg(xargs[n], XmNlabelString, label); n++;
51 }
52
53 char *name = args.name ? (char*)args.name : "label";
54 Widget w = XmCreateLabel(parent, name, xargs, n);
55 XtManageChild(w);
56 ctn->add(ctn, w);
57
58 XmStringFree(label);
59 return w;
60 }
61
62 UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs args) {
63 return label_create(obj, args, XmALIGNMENT_CENTER);
64 }
65
66 UIWIDGET ui_llabel_create(UiObject* obj, UiLabelArgs args) {
67 return label_create(obj, args, XmALIGNMENT_BEGINNING);
68 }
69
70 UIWIDGET ui_rlabel_create(UiObject* obj, UiLabelArgs args) {
71 return label_create(obj, args, XmALIGNMENT_END);
72 }

mercurial