ui/motif/container.c

Mon, 13 Jan 2025 22:44:01 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 13 Jan 2025 22:44:01 +0100
changeset 443
3379c8a5b6bb
parent 426
3eb26df703bf
permissions
-rw-r--r--

implement ui_customwidget_create for Motif

4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
4 * Copyright 2024 Olaf Wintermann. All rights reserved.
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 61
diff changeset
31 #include <inttypes.h>
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "container.h"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "../common/context.h"
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
35 #include "../common/object.h"
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
37 #include "Grid.h"
60
7cd1b8890302 added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
38
443
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
39
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
40 UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) {
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
41 Arg xargs[64];
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
42 int n = 0;
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
43
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
44 UiContainerPrivate *ctn = ui_obj_container(obj);
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
45 UI_APPLY_LAYOUT(ctn->layout, args);
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
46
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
47 Widget parent = ctn->prepare(ctn, xargs, &n);
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
48 Widget widget = create_widget(obj, args, userdata, parent, xargs, n);
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
49 XtManageChild(widget);
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
50 ctn->add(ctn, widget);
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
51
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
52 return widget;
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
53 }
3379c8a5b6bb implement ui_customwidget_create for Motif
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 426
diff changeset
54
407
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
55 /* ---------------------------- Box Container ---------------------------- */
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
56
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
57 static UIWIDGET box_create(UiObject *obj, UiContainerArgs args, UiBoxOrientation orientation) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
58 UiContainerPrivate *ctn = ui_obj_container(obj);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
59 UI_APPLY_LAYOUT(ctn->layout, args);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
60
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
61 Arg xargs[16];
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
62 int n = 0;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
63
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
64 if(orientation == UI_BOX_VERTICAL) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
65 //XtSetArg(xargs[n], gridRowSpacing, args.spacing); n++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
66 } else {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
67 //XtSetArg(xargs[n], gridColumnSpacing, args.spacing); n++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
68 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
69
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
70 Widget parent = ctn->prepare(ctn, xargs, &n);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
71 Widget grid = XtCreateManagedWidget(args.name ? args.name : "boxcontainer", gridClass, parent, xargs, n);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
72 ctn->add(ctn, grid);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
73
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
74 UiContainerX *container = ui_box_container(obj, grid, orientation);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
75 uic_object_push_container(obj, container);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
76
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
77 return grid;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
78 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
79
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
80 // public
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
81 UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
82 return box_create(obj, args, UI_BOX_VERTICAL);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
83 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
84
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
85 // public
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
86 UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
87 return box_create(obj, args, UI_BOX_HORIZONTAL);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
88 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
89
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
90 UiContainerX* ui_box_container(UiObject *obj, Widget grid, UiBoxOrientation orientation) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
91 UiBoxContainer *ctn = ui_malloc(obj->ctx, sizeof(UiBoxContainer));
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
92 memset(ctn, 0, sizeof(UiBoxContainer));
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
93 ctn->container.prepare = orientation == UI_BOX_VERTICAL ? ui_vbox_prepare : ui_hbox_prepare;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
94 ctn->container.add = ui_box_container_add;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
95 ctn->container.widget = grid;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
96 ctn->n = 0;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
97 return (UiContainerX*)ctn;
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 61
diff changeset
98 }
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 61
diff changeset
99
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
100 static Widget ui_box_container_prepare(UiBoxContainer *box, Arg *args, int *n) {
64
6ef2c7f73a30 added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 63
diff changeset
101 int a = *n;
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
102 box->n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
103 return box->container.widget;
61
7ee124a58fe3 improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
104 }
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
105
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
106 Widget ui_vbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
107 UiBoxContainer *box = (UiBoxContainer*)ctn;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
108 int a = *n;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
109 XtSetArg(args[a], gridRow, box->n); a++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
110 if(box->container.layout.fill == UI_ON) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
111 XtSetArg(args[a], gridVExpand, TRUE); a++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
112 XtSetArg(args[a], gridVFill, TRUE); a++;
64
6ef2c7f73a30 added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 63
diff changeset
113 }
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
114 XtSetArg(args[a], gridHExpand, TRUE); a++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
115 XtSetArg(args[a], gridHFill, TRUE); a++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
116 *n = a;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
117 return ui_box_container_prepare(box, args, n);
91
c13e344fa55f drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
118 }
c13e344fa55f drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
119
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
120 Widget ui_hbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
121 UiBoxContainer *box = (UiBoxContainer*)ctn;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
122 int a = *n;
407
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
123 XtSetArg(args[a], gridColumn, box->n); a++;
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
124 if(box->container.layout.fill == UI_ON) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
125 XtSetArg(args[a], gridHExpand, TRUE); a++;
407
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
126 XtSetArg(args[a], gridHFill, TRUE); a++;
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
127 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
128 XtSetArg(args[a], gridVExpand, TRUE); a++;
407
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
129 XtSetArg(args[a], gridVFill, TRUE); a++;
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
130 *n = a;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
131 return ui_box_container_prepare(box, args, n);
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 36
diff changeset
132 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 36
diff changeset
133
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
134 void ui_box_container_add(UiContainerPrivate *ctn, Widget widget) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
135 ui_reset_layout(ctn->layout);
91
c13e344fa55f drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 76
diff changeset
136
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 36
diff changeset
137 }
407
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
138
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
139
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
140 /* ---------------------------- Grid Container ---------------------------- */
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
141
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
142 // public
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
143 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
144 Arg xargs[16];
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
145 int n = 0;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
146
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
147 UiContainerPrivate *ctn = ui_obj_container(obj);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
148 UI_APPLY_LAYOUT(ctn->layout, args);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
149
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
150 Widget parent = ctn->prepare(ctn, xargs, &n);
426
3eb26df703bf implement Grid col/row spacing (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 424
diff changeset
151 XtSetArg(xargs[n], gridMargin, args.margin); n++;
3eb26df703bf implement Grid col/row spacing (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 424
diff changeset
152 XtSetArg(xargs[n], gridColumnSpacing, args.columnspacing); n++;
3eb26df703bf implement Grid col/row spacing (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 424
diff changeset
153 XtSetArg(xargs[n], gridRowSpacing, args.rowspacing); n++;
407
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
154 Widget grid = XtCreateManagedWidget(args.name ? args.name : "gridcontainer", gridClass, parent, xargs, n);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
155 ctn->add(ctn, grid);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
156
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
157 UiContainerX *container = ui_grid_container(obj, grid);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
158 uic_object_push_container(obj, container);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
159
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
160 return grid;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
161 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
162
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
163 UiContainerX* ui_grid_container(UiObject *obj, Widget grid) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
164 UiGridContainer *ctn = ui_malloc(obj->ctx, sizeof(UiGridContainer));
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
165 memset(ctn, 0, sizeof(UiBoxContainer));
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
166 ctn->container.prepare = ui_grid_container_prepare;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
167 ctn->container.add = ui_grid_container_add;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
168 ctn->container.widget = grid;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
169 ctn->x = 0;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
170 ctn->y = 0;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
171 return (UiContainerX*)ctn;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
172 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
173
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
174 Widget ui_grid_container_prepare(UiContainerPrivate *ctn, Arg *args, int *n) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
175 UiGridContainer *grid = (UiGridContainer*)ctn;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
176 if(ctn->layout.newline) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
177 grid->y++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
178 grid->x = 0;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
179 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
180
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
181 int a = *n;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
182 XtSetArg(args[a], gridColumn, grid->x); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
183 XtSetArg(args[a], gridRow, grid->y); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
184 if(ctn->layout.colspan > 0) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
185 XtSetArg(args[a], gridColspan, ctn->layout.colspan); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
186 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
187 if(ctn->layout.rowspan > 0) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
188 XtSetArg(args[a], gridRowspan, ctn->layout.rowspan); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
189 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
190
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
191 if(grid->container.layout.fill == UI_ON) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
192 grid->container.layout.hfill = TRUE;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
193 grid->container.layout.vfill = TRUE;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
194 grid->container.layout.hexpand = TRUE;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
195 grid->container.layout.vexpand = TRUE;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
196 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
197
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
198 if(grid->container.layout.hfill) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
199 XtSetArg(args[a], gridHFill, TRUE); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
200 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
201 if(grid->container.layout.vfill) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
202 XtSetArg(args[a], gridVFill, TRUE); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
203 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
204 if(grid->container.layout.hexpand) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
205 XtSetArg(args[a], gridHExpand, TRUE); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
206 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
207 if(grid->container.layout.vexpand) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
208 XtSetArg(args[a], gridVExpand, TRUE); a++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
209 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
210
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
211 *n = a;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
212 return ctn->widget;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
213 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
214
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
215 void ui_grid_container_add(UiContainerPrivate *ctn, Widget widget) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
216 UiGridContainer *grid = (UiGridContainer*)ctn;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
217 grid->x++;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
218 ui_reset_layout(ctn->layout);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
219 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
220
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
221
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
222 /* -------------------- Container Helper Functions -------------------- */
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
223
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
224 void ui_container_begin_close(UiObject *obj) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
225 UiContainerPrivate *ct = ui_obj_container(obj);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
226 ct->container.close = 1;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
227 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
228
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
229 int ui_container_finish(UiObject *obj) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
230 UiContainerPrivate *ct = ui_obj_container(obj);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
231 if(ct->container.close) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
232 ui_end_new(obj);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
233 return 0;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
234 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
235 return 1;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
236 }
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
237
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
238
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
239 /*
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
240 * -------------------- Layout Functions --------------------
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
241 *
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
242 * functions for setting layout attributes for the current container
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
243 *
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
244 */
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
245
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
246 void ui_newline(UiObject *obj) {
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
247 UiContainerPrivate *ct = ui_obj_container(obj);
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
248 ct->layout.newline = TRUE;
8ea123dd89db semi functional grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
249 }

mercurial