Wed, 20 Jan 2016 17:37:52 +0100
added drawing area (Qt)
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 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2014 Olaf Wintermann. All rights reserved. |
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 | |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
37 | #define UI_GRID_MAX_COLUMNS 512 |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
38 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
39 | static UiBool ui_lb2bool(UiLayoutBool b) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
40 | return b == UI_LAYOUT_TRUE ? TRUE : FALSE; |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
41 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
42 | |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
43 | static UiLayoutBool ui_bool2lb(UiBool b) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
44 | return b ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE; |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
45 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
46 | |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
47 | |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | UiContainer* ui_frame_container(UiObject *obj, Widget frame) { |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
49 | UiContainer *ct = ucx_mempool_calloc( |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | obj->ctx->mempool, |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
51 | 1, |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | sizeof(UiContainer)); |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | ct->widget = frame; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
54 | ct->prepare = ui_frame_container_prepare; |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | ct->add = ui_frame_container_add; |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | return ct; |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | } |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
59 | Widget ui_frame_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill) { |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | return ct->widget; |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | } |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
62 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
63 | void ui_frame_container_add(UiContainer *ct, Widget widget) { |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
64 | ui_reset_layout(ct->layout); |
76
3782827378ab
added context menus (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
65
diff
changeset
|
65 | ct->current = widget; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
66 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
67 | |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
68 | |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
69 | UiContainer* ui_box_container(UiObject *obj, Widget box, UiBoxOrientation orientation) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
70 | UiBoxContainer *ct = ucx_mempool_calloc( |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
71 | obj->ctx->mempool, |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
72 | 1, |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
73 | sizeof(UiBoxContainer)); |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
74 | ct->container.widget = box; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
75 | ct->container.prepare = ui_box_container_prepare; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
76 | ct->container.add = ui_box_container_add; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
77 | ct->orientation = orientation; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
78 | return (UiContainer*)ct; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
79 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
80 | |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
81 | Widget ui_box_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill) { |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
82 | UiBoxContainer *bc = (UiBoxContainer*)ct; |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
83 | if(ct->layout.fill != UI_LAYOUT_UNDEFINED) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
84 | fill = ui_lb2bool(ct->layout.fill); |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
85 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
86 | |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
87 | if(bc->has_fill && fill) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
88 | fprintf(stderr, "UiError: container has 2 filled widgets"); |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
89 | fill = FALSE; |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
90 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
91 | if(fill) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
92 | bc->has_fill = TRUE; |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
93 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
94 | |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
95 | int a = *n; |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
96 | // determine fixed and dynamic attachments |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
97 | void *f1; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
98 | void *f2; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
99 | void *d1; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
100 | void *d2; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
101 | void *w1; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
102 | void *w2; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
103 | if(bc->orientation == UI_BOX_VERTICAL) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
104 | f1 = XmNleftAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
105 | f2 = XmNrightAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
106 | d1 = XmNtopAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
107 | d2 = XmNbottomAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
108 | w1 = XmNtopWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
109 | w2 = XmNbottomWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
110 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
111 | } else { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
112 | f1 = XmNtopAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
113 | f2 = XmNbottomAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
114 | d1 = XmNleftAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
115 | d2 = XmNrightAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
116 | w1 = XmNleftWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
117 | w2 = XmNrightWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
118 | } |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
119 | XtSetArg(args[a], f1, XmATTACH_FORM); a++; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
120 | XtSetArg(args[a], f2, XmATTACH_FORM); a++; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
121 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
122 | if(fill) { |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
123 | XtSetArg(args[a], d2, XmATTACH_FORM); a++; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
124 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
125 | if(bc->prev_widget) { |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
126 | XtSetArg(args[a], d1, XmATTACH_WIDGET); a++; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
127 | XtSetArg(args[a], w1, bc->prev_widget); a++; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
128 | } else { |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
129 | XtSetArg(args[a], d1, XmATTACH_FORM); a++; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
130 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
131 | |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
132 | *n = a; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
133 | return ct->widget; |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
134 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
135 | |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
136 | void ui_box_container_add(UiContainer *ct, Widget widget) { |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
137 | UiBoxContainer *bc = (UiBoxContainer*)ct; |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
138 | // determine dynamic attachments |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
139 | void *d1; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
140 | void *d2; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
141 | void *w1; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
142 | void *w2; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
143 | if(bc->orientation == UI_BOX_VERTICAL) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
144 | d1 = XmNtopAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
145 | d2 = XmNbottomAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
146 | w1 = XmNtopWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
147 | w2 = XmNbottomWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
148 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
149 | } else { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
150 | d1 = XmNleftAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
151 | d2 = XmNrightAttachment; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
152 | w1 = XmNleftWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
153 | w2 = XmNrightWidget; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
154 | } |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
155 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
156 | if(bc->prev_widget) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
157 | int v = 0; |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
158 | XtVaGetValues(bc->prev_widget, d2, &v, 0); |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
159 | if(v == XmATTACH_FORM) { |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
160 | XtVaSetValues( |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
161 | bc->prev_widget, |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
162 | d2, |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
163 | XmATTACH_WIDGET, |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
164 | w2, |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
165 | widget, |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
166 | 0); |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
167 | XtVaSetValues( |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
168 | widget, |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
169 | d1, |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
170 | XmATTACH_NONE, |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
171 | d2, |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
172 | XmATTACH_FORM, |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
173 | 0); |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
174 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
175 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
176 | bc->prev_widget = widget; |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
177 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
178 | ui_reset_layout(ct->layout); |
76
3782827378ab
added context menus (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
65
diff
changeset
|
179 | ct->current = widget; |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
180 | } |
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
181 | |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
182 | UiContainer* ui_grid_container(UiObject *obj, Widget form, int columnspacing, int rowspacing) { |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
183 | UiGridContainer *ct = ucx_mempool_calloc( |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
184 | obj->ctx->mempool, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
185 | 1, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
186 | sizeof(UiGridContainer)); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
187 | ct->container.widget = form; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
188 | ct->container.prepare = ui_grid_container_prepare; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
189 | ct->container.add = ui_grid_container_add; |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
190 | ct->columnspacing = columnspacing; |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
191 | ct->rowspacing = rowspacing; |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
192 | return (UiContainer*)ct; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
193 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
194 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
195 | void ui_grid_newline(UiGridContainer *grid) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
196 | if(grid->current) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
197 | grid->current = NULL; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
198 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
199 | grid->container.layout.newline = FALSE; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
200 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
201 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
202 | Widget ui_grid_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
203 | UiGridContainer *grid = (UiGridContainer*)ct; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
204 | if(ct->layout.newline) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
205 | ui_grid_newline(grid); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
206 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
207 | return ct->widget; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
208 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
209 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
210 | void ui_grid_container_add(UiContainer *ct, Widget widget) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
211 | UiGridContainer *grid = (UiGridContainer*)ct; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
212 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
213 | if(grid->current) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
214 | grid->current = ucx_list_append(grid->current, widget); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
215 | } else { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
216 | grid->current = ucx_list_append(grid->current, widget); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
217 | grid->lines = ucx_list_append(grid->lines, grid->current); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
218 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
219 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
220 | ui_reset_layout(ct->layout); |
76
3782827378ab
added context menus (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
65
diff
changeset
|
221 | ct->current = widget; |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
222 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
223 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
224 | static void ui_grid_resize(Widget widget, XtPointer udata, XtPointer cdata) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
225 | UiGridContainer *grid = udata; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
226 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
227 | UcxList *rowdim = NULL; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
228 | int coldim[UI_GRID_MAX_COLUMNS]; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
229 | memset(coldim, 0, UI_GRID_MAX_COLUMNS*sizeof(int)); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
230 | int numcol = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
231 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
232 | // get the minimum size of the columns and rows |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
233 | int sumw = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
234 | int sumh = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
235 | UCX_FOREACH(row, grid->lines) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
236 | int rheight = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
237 | int i=0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
238 | int sum_width = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
239 | UCX_FOREACH(elm, row->data) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
240 | Widget w = elm->data; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
241 | int widget_width = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
242 | int widget_height = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
243 | XtVaGetValues( |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
244 | w, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
245 | XmNwidth, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
246 | &widget_width, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
247 | XmNheight, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
248 | &widget_height, |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
249 | 0); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
250 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
251 | // get the maximum height in this row |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
252 | if(widget_height > rheight) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
253 | rheight = widget_height; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
254 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
255 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
256 | // get the maximum width in this column |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
257 | if(widget_width > coldim[i]) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
258 | coldim[i] = widget_width; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
259 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
260 | sum_width += widget_width; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
261 | if(sum_width > sumw) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
262 | sumw = sum_width; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
263 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
264 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
265 | i++; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
266 | if(i > numcol) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
267 | numcol = i; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
268 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
269 | } |
63
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
270 | rowdim = ucx_list_append(rowdim, (void*)(intptr_t)rheight); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
271 | sumh += rheight; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
272 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
273 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
274 | // check container size |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
275 | int gwidth = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
276 | int gheight = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
277 | XtVaGetValues(widget, XmNwidth, &gwidth, XmNheight, &gheight, NULL); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
278 | if(gwidth < sumw || gheight < sumh) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
279 | XtVaSetValues(widget, XmNwidth, sumw, XmNheight, sumh, NULL); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
280 | ucx_list_free(rowdim); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
281 | return; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
282 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
283 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
284 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
285 | // adjust the positions of all children |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
286 | int y = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
287 | UCX_FOREACH(row, grid->lines) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
288 | int x = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
289 | int i=0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
290 | UCX_FOREACH(elm, row->data) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
291 | Widget w = elm->data; |
63
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
292 | XtVaSetValues( |
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
293 | w, |
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
294 | XmNx, x, |
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
295 | XmNy, y, |
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
296 | XmNwidth, coldim[i], |
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
297 | XmNheight, rowdim->data, |
46a42f0c4f93
added textfield and some container fixes (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
298 | NULL); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
299 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
300 | x += coldim[i]; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
301 | i++; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
302 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
303 | y += (intptr_t)rowdim->data; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
304 | rowdim = rowdim->next; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
305 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
306 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
307 | ucx_list_free(rowdim); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
308 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
309 | |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
310 | UiContainer* ui_tabview_container(UiObject *obj, Widget frame) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
311 | UiTabViewContainer *ct = ucx_mempool_calloc( |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
312 | obj->ctx->mempool, |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
313 | 1, |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
314 | sizeof(UiTabViewContainer)); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
315 | ct->context = obj->ctx; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
316 | ct->container.widget = frame; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
317 | ct->container.prepare = ui_tabview_container_prepare; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
318 | ct->container.add = ui_tabview_container_add; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
319 | return (UiContainer*)ct; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
320 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
321 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
322 | Widget ui_tabview_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
323 | int a = *n; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
324 | XtSetArg(args[a], XmNleftAttachment, XmATTACH_FORM); a++; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
325 | XtSetArg(args[a], XmNrightAttachment, XmATTACH_FORM); a++; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
326 | XtSetArg(args[a], XmNtopAttachment, XmATTACH_FORM); a++; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
327 | XtSetArg(args[a], XmNbottomAttachment, XmATTACH_FORM); a++; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
328 | *n = a; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
329 | return ct->widget; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
330 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
331 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
332 | void ui_tabview_container_add(UiContainer *ct, Widget widget) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
333 | UiTabViewContainer *tabview = (UiTabViewContainer*)ct; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
334 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
335 | if(tabview->current) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
336 | XtUnmanageChild(tabview->current); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
337 | } |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
338 | |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
339 | tabview->current = widget; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
340 | tabview->tabs = ucx_list_append(tabview->tabs, widget); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
341 | |
65
4697592e24ba
added label, grid container, simple tabview and textfield (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
342 | ui_select_tab(ct->widget, 0); |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
343 | ui_reset_layout(ct->layout); |
76
3782827378ab
added context menus (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
65
diff
changeset
|
344 | ct->current = widget; |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
345 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
346 | |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
347 | UIWIDGET ui_box(UiObject *obj, UiBoxOrientation orientation) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
348 | UiContainer *ct = uic_get_current_container(obj); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
349 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
350 | Arg args[16]; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
351 | int n = 0; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
352 | Widget parent = ct->prepare(ct, args, &n, TRUE); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
353 | Widget form = XmCreateForm(parent, "vbox", args, n); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
354 | ct->add(ct, form); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
355 | XtManageChild(form); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
356 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
357 | UiObject *newobj = uic_object_new(obj, form); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
358 | newobj->container = ui_box_container(obj, form, orientation); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
359 | uic_obj_add(obj, newobj); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
360 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
361 | return form; |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
362 | } |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
363 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
364 | UIWIDGET ui_vbox(UiObject *obj) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
365 | return ui_box(obj, UI_BOX_VERTICAL); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
366 | } |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
367 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
368 | UIWIDGET ui_hbox(UiObject *obj) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
369 | return ui_box(obj, UI_BOX_HORIZONTAL); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
370 | } |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
371 | |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
372 | UIWIDGET ui_grid(UiObject *obj) { |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
373 | return ui_grid_sp(obj, 0, 0); |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
374 | } |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
375 | |
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
376 | UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) { |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
377 | UiContainer *ct = uic_get_current_container(obj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
378 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
379 | Arg args[16]; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
380 | int n = 0; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
381 | Widget parent = ct->prepare(ct, args, &n, TRUE); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
382 | Widget grid = XmCreateDrawingArea(parent, "grid", args, n); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
383 | ct->add(ct, grid); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
384 | XtManageChild(grid); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
385 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
386 | UiObject *newobj = uic_object_new(obj, grid); |
99
ea1a2d5de765
improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
93
diff
changeset
|
387 | newobj->container = ui_grid_container(obj, grid, columnspacing, rowspacing); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
388 | uic_obj_add(obj, newobj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
389 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
390 | XtAddCallback (grid, XmNresizeCallback , ui_grid_resize, newobj->container); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
391 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
392 | return grid; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
393 | } |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
394 | |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
395 | UIWIDGET ui_sidebar(UiObject *obj) { |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
396 | UiContainer *ct = uic_get_current_container(obj); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
397 | |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
398 | Arg args[16]; |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
399 | int n = 0; |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
400 | |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
401 | XtSetArg(args[n], XmNorientation, XmHORIZONTAL); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
402 | n++; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
403 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
404 | Widget parent = ct->prepare(ct, args, &n, TRUE); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
405 | Widget pane = XmCreatePanedWindow(parent, "pane", args, n); |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
406 | ct->add(ct, pane); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
407 | XtManageChild(pane); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
408 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
409 | // add sidebar widget |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
410 | Widget sidebar = XmCreateForm(pane, "sidebar", args, 0); |
36
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
411 | XtManageChild(sidebar); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
412 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
413 | UiObject *left = uic_object_new(obj, sidebar); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
414 | left->container = ui_box_container(left, sidebar, UI_BOX_VERTICAL); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
415 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
416 | // add content widget |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
417 | XtSetArg (args[0], XmNpaneMaximum, 8000); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
418 | Widget content = XmCreateForm(pane, "content_area", args, 1); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
419 | XtManageChild(content); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
420 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
421 | UiObject *right = uic_object_new(obj, content); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
422 | right->container = ui_box_container(right, content, UI_BOX_VERTICAL); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
423 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
424 | uic_obj_add(obj, right); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
425 | uic_obj_add(obj, left); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
426 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
427 | return sidebar; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
428 | } |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
429 | |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
430 | UIWIDGET ui_tabview(UiObject *obj) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
431 | UiContainer *ct = uic_get_current_container(obj); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
432 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
433 | // create a simple frame as container widget |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
434 | // when tabs are selected, the current child will be replaced by the |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
435 | // the new tab widget |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
436 | Arg args[16]; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
437 | int n = 0; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
438 | XtSetArg(args[n], XmNshadowType, XmSHADOW_ETCHED_OUT); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
439 | n++; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
440 | XtSetArg(args[n], XmNshadowThickness, 0); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
441 | n++; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
442 | Widget parent = ct->prepare(ct, args, &n, TRUE); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
443 | Widget form = XmCreateForm(parent, "tabview", args, n); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
444 | ct->add(ct, form); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
445 | XtManageChild(form); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
446 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
447 | UiObject *tabviewobj = uic_object_new(obj, form); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
448 | tabviewobj->container = ui_tabview_container(obj, form); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
449 | uic_obj_add(obj, tabviewobj); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
450 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
451 | XtVaSetValues(form, XmNuserData, tabviewobj->container, NULL); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
452 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
453 | return form; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
454 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
455 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
456 | void ui_tab(UiObject *obj, char *title) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
457 | UiContainer *ct = uic_get_current_container(obj); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
458 | ct->layout.label = title; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
459 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
460 | ui_vbox(obj); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
461 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
462 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
463 | void ui_select_tab(UIWIDGET tabview, int tab) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
464 | UiTabViewContainer *ct = NULL; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
465 | XtVaGetValues(tabview, XmNuserData, &ct, NULL); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
466 | if(ct) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
467 | XtUnmanageChild(ct->current); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
468 | UcxList *elm = ucx_list_get(ct->tabs, tab); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
469 | if(elm) { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
470 | XtManageChild(elm->data); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
471 | ct->current = elm->data; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
472 | } else { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
473 | fprintf(stderr, "UiError: front tab index: %d\n", tab); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
474 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
475 | } else { |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
476 | fprintf(stderr, "UiError: widget is not a tabview\n"); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
477 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
478 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
479 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
480 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
481 | /* document tabview */ |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
482 | |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
483 | static void ui_tabbar_resize(Widget widget, XtPointer udata, XtPointer cdata) { |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
484 | MotifTabbedPane *v = (MotifTabbedPane*)udata; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
485 | |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
486 | int width = 0; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
487 | int height = 0; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
488 | XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
489 | int button_width = width / 4; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
490 | int x = 0; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
491 | UCX_FOREACH(elm, v->tabs) { |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
492 | UiTab *tab = elm->data; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
493 | XtVaSetValues( |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
494 | tab->tab_button, |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
495 | XmNx, x, |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
496 | XmNy, 0, |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
497 | XmNwidth, |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
498 | button_width, |
93
5223de7979e2
motif tabview fix
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
499 | |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
500 | NULL); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
501 | x += button_width; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
502 | } |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
503 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
504 | if(height <= v->height) { |
93
5223de7979e2
motif tabview fix
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
505 | XtVaSetValues(widget, XmNheight, v->height + 4, NULL); |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
506 | } |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
507 | } |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
508 | |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
509 | static void ui_tabbar_expose(Widget widget, XtPointer udata, XtPointer cdata) { |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
510 | MotifTabbedPane *v = (MotifTabbedPane*)udata; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
511 | XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)cdata; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
512 | XEvent *event = cbs->event; |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
513 | Display *dpy = XtDisplay(widget); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
514 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
515 | XGCValues gcvals; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
516 | GC gc; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
517 | Pixel fgpix; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
518 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
519 | int tab_x; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
520 | int tab_width; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
521 | XtVaGetValues(v->current->tab_button, XmNx, &tab_x, XmNwidth, &tab_width, XmNhighlightColor, &fgpix, NULL); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
522 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
523 | gcvals.foreground = v->bg1; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
524 | gc = XCreateGC( dpy, XtWindow(widget), (GCForeground), &gcvals); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
525 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
526 | int width = 0; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
527 | int height = 0; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
528 | XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
529 | XFillRectangle(dpy, XtWindow(widget), gc, 0, 0, width, height); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
530 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
531 | gcvals.foreground = fgpix; |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
532 | gc = XCreateGC( dpy, XtWindow(widget), (GCForeground), &gcvals); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
533 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
534 | XFillRectangle(dpy, XtWindow(widget), gc, tab_x, 0, tab_width, height); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
535 | |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
536 | } |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
537 | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
538 | UiTabbedPane* ui_tabbed_document_view(UiObject *obj) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
539 | int n = 0; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
540 | Arg args[16]; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
541 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
542 | UiContainer *ct = uic_get_current_container(obj); |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
543 | Widget parent = ct->prepare(ct, args, &n, TRUE); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
544 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
545 | Widget tabview = XmCreateForm(parent, "tabview_form", args, n); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
546 | XtManageChild(tabview); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
547 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
548 | XtSetArg(args[0], XmNorientation, XmHORIZONTAL); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
549 | XtSetArg(args[1], XmNpacking, XmPACK_TIGHT); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
550 | XtSetArg(args[2], XmNspacing, 1); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
551 | XtSetArg(args[3], XmNleftAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
552 | XtSetArg(args[4], XmNrightAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
553 | XtSetArg(args[5], XmNtopAttachment, XmATTACH_FORM); |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
554 | XtSetArg(args[6], XmNmarginWidth, 0); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
555 | XtSetArg(args[7], XmNmarginHeight, 0); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
556 | Widget tabbar = XmCreateDrawingArea(tabview, "tabbar", args, 8); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
557 | XtManageChild(tabbar); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
558 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
559 | XtSetArg(args[0], XmNleftAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
560 | XtSetArg(args[1], XmNrightAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
561 | XtSetArg(args[2], XmNtopAttachment, XmATTACH_WIDGET); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
562 | XtSetArg(args[3], XmNtopWidget, tabbar); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
563 | XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
564 | XtSetArg(args[5], XmNshadowThickness, 0); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
565 | Widget tabct = XmCreateForm(tabview, "tabview", args, 6); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
566 | XtManageChild(tabct); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
567 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
568 | MotifTabbedPane *tabbedpane = ui_malloc(obj->ctx, sizeof(MotifTabbedPane)); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
569 | tabbedpane->view.ctx = uic_current_obj(obj)->ctx; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
570 | tabbedpane->view.widget = tabct; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
571 | tabbedpane->view.document = NULL; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
572 | tabbedpane->tabbar = tabbar; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
573 | tabbedpane->tabs = NULL; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
574 | tabbedpane->current = NULL; |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
575 | tabbedpane->height = 0; |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
576 | |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
577 | XtAddCallback(tabbar, XmNresizeCallback , ui_tabbar_resize, tabbedpane); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
578 | XtAddCallback(tabbar, XmNexposeCallback, ui_tabbar_expose, tabbedpane); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
579 | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
580 | return &tabbedpane->view; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
581 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
582 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
583 | UiObject* ui_document_tab(UiTabbedPane *view) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
584 | MotifTabbedPane *v = (MotifTabbedPane*)view; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
585 | int n = 0; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
586 | Arg args[16]; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
587 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
588 | // hide the current tab content |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
589 | if(v->current) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
590 | XtUnmanageChild(v->current->content->widget); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
591 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
592 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
593 | UiTab *tab = ui_malloc(view->ctx, sizeof(UiTab)); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
594 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
595 | // create the new tab content |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
596 | XtSetArg(args[0], XmNshadowThickness, 0); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
597 | XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
598 | XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
599 | XtSetArg(args[3], XmNtopAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
600 | XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
601 | XtSetArg(args[5], XmNuserData, tab); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
602 | Widget frame = XmCreateFrame(view->widget, "tab", args, 6); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
603 | XtManageChild(frame); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
604 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
605 | UiObject *content = ui_malloc(view->ctx, sizeof(UiObject)); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
606 | content->widget = NULL; // initialization for uic_context() |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
607 | content->ctx = uic_context(content, view->ctx->mempool); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
608 | content->ctx->parent = view->ctx; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
609 | content->ctx->set_document = ui_tab_set_document; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
610 | content->ctx->detach_document = ui_tab_detach_document; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
611 | content->widget = frame; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
612 | content->window = view->ctx->obj->window; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
613 | content->container = ui_frame_container(content, frame); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
614 | content->next = NULL; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
615 | |
53
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
616 | // add tab button |
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
617 | v->tabs = ucx_list_append_a(view->ctx->mempool->allocator, v->tabs, tab); |
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
618 | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
619 | XmString label = XmStringCreateLocalized("tab"); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
620 | XtSetArg(args[0], XmNlabelString, label); |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
621 | XtSetArg(args[1], XmNshadowThickness, 0); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
622 | XtSetArg(args[2], XmNhighlightThickness, 0); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
623 | |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
624 | Widget button = XmCreatePushButton(v->tabbar, "tab_button", args, 3); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
625 | tab->tabbedpane = v; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
626 | tab->content = content; |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
627 | tab->tab_button = button; |
53
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
628 | XtManageChild(button); |
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
629 | XtAddCallback( |
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
630 | button, |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
631 | XmNactivateCallback, |
53
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
632 | (XtCallbackProc)ui_tab_button_callback, |
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
633 | tab); |
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
634 | |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
635 | if(v->height == 0) { |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
636 | XtVaGetValues( |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
637 | button, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
638 | XmNarmColor, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
639 | &v->bg1, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
640 | XmNbackground, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
641 | &v->bg2, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
642 | XmNheight, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
643 | &v->height, |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
644 | NULL); |
93
5223de7979e2
motif tabview fix
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
645 | v->height += 2; // border |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
646 | } |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
647 | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
648 | ui_change_tab(v, tab); |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
649 | ui_tabbar_resize(v->tabbar, v, NULL); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
650 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
651 | return content; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
652 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
653 | |
53
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
654 | void ui_tab_button_callback(Widget widget, UiTab *tab, XtPointer d) { |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
655 | MotifTabbedPane *t = tab->tabbedpane; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
656 | if(t->current) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
657 | XtUnmanageChild(t->current->content->widget); |
53
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
658 | XtVaSetValues(t->current->tab_button, XmNset, 0, NULL); |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
659 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
660 | XtManageChild(tab->content->widget); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
661 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
662 | ui_change_tab(t, tab); |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
663 | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
664 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
665 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
666 | void ui_change_tab(MotifTabbedPane *pane, UiTab *tab) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
667 | UiContext *ctx = tab->content->ctx; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
668 | ctx->parent->set_document(ctx->parent, ctx->document); |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
669 | |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
670 | if(pane->current) { |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
671 | XtVaSetValues(pane->current->tab_button, XmNshadowThickness, 0, XmNbackground, pane->bg1, NULL); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
672 | } |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
673 | XtVaSetValues(tab->tab_button, XmNshadowThickness, 1, XmNbackground, pane->bg2, NULL); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
674 | |
91
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
675 | pane->current = tab; |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
676 | pane->index = ucx_list_find(pane->tabs, tab, NULL, NULL); |
c13e344fa55f
drawingarea based tab widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
76
diff
changeset
|
677 | printf("index: %d\n", pane->index); |
92
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
678 | |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
679 | // redraw tabbar |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
680 | Display *dpy = XtDisplay(pane->tabbar); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
681 | Window window = XtWindow(pane->tabbar); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
682 | if(dpy && window) { |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
683 | XClearArea(dpy, XtWindow(pane->tabbar), 0, 0, 0, 0, TRUE); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
684 | XFlush(dpy); |
d56175dd931e
improved motif tab look
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
685 | } |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
686 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
687 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
688 | void ui_tab_set_document(UiContext *ctx, void *document) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
689 | if(ctx->parent->document) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
690 | //ctx->parent->detach_document(ctx->parent, ctx->parent->document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
691 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
692 | uic_context_set_document(ctx, document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
693 | //uic_context_set_document(ctx->parent, document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
694 | //ctx->parent->document = document; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
695 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
696 | UiTab *tab = NULL; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
697 | XtVaGetValues( |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
698 | ctx->obj->widget, |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
699 | XmNuserData, |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
700 | &tab, |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
701 | NULL); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
702 | if(tab) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
703 | if(tab->tabbedpane->current == tab) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
704 | ctx->parent->set_document(ctx->parent, ctx->document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
705 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
706 | } else { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
707 | fprintf(stderr, "UiError: ui_bar_set_document: Cannot set document"); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
708 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
709 | } |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
710 | |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
711 | void ui_tab_detach_document(UiContext *ctx, void *document) { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
712 | uic_context_detach_document(ctx->parent, document); |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
713 | } |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
714 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
715 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
716 | /* |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
717 | * -------------------- Layout Functions -------------------- |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
718 | * |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
719 | * functions for setting layout attributes for the current container |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
720 | * |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
721 | */ |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
722 | |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
723 | void ui_layout_fill(UiObject *obj, UiBool fill) { |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
724 | UiContainer *ct = uic_get_current_container(obj); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
725 | ct->layout.fill = ui_bool2lb(fill); |
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
726 | } |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
727 | |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
728 | void ui_newline(UiObject *obj) { |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
729 | UiContainer *ct = uic_get_current_container(obj); |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
730 | ct->layout.newline = TRUE; |
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
731 | } |