Wed, 21 Jan 2015 20:38:21 +0100
fixed memory allocation bug
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2014 Olaf Wintermann. All rights reserved. |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
4e66271541e8
added table view (Motif)
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 |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include <stdio.h> |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include <stdlib.h> |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <string.h> |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
32 | #include <inttypes.h> |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #include "tree.h" |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include "container.h" |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | #include "../common/object.h" |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
38 | #include "../common/context.h" |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | #include "../../ucx/utils.h" |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | UIWIDGET ui_table(UiObject *obj, UiList *model, UiModelInfo *modelinfo) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | // TODO: check if modelinfo is complete |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
44 | Arg args[32]; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | int n = 0; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
47 | // create scrolled window |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
48 | UiContainer *ct = uic_get_current_container(obj); |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
49 | Widget parent = ct->prepare(ct, args, &n, TRUE); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
50 | |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
51 | XtSetArg(args[n], XmNscrollingPolicy, XmAUTOMATIC); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
52 | n++; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
53 | XtSetArg(args[n], XmNshadowThickness, 0); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
54 | n++; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
55 | Widget scrollw = XmCreateScrolledWindow(parent, "scroll_win", args, n); |
60
7cd1b8890302
added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
56 | ct->add(ct, scrollw); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
57 | XtManageChild(scrollw); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
58 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | // create table headers |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | XmStringTable header = (XmStringTable)XtMalloc( |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | modelinfo->columns * sizeof(XmString)); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | for(int i=0;i<modelinfo->columns;i++) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | header[i] = XmStringCreateLocalized(modelinfo->titles[i]); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | } |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
65 | n = 0; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | XtSetArg(args[n], XmNdetailColumnHeading, header); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | n++; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | XtSetArg(args[n], XmNdetailColumnHeadingCount, modelinfo->columns); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | n++; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | // set res |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | XtSetArg(args[n], XmNlayoutType, XmDETAIL); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | n++; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | n++; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | n++; |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
78 | XtSetArg(args[n], XmNwidth, 600); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
79 | n++; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | // create widget |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
82 | //UiContainer *ct = uic_get_current_container(obj); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
83 | //Widget parent = ct->add(ct, args, &n); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
85 | Widget container = XmCreateContainer(scrollw, "table", args, n); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | XtManageChild(container); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
88 | // add callbacks |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
89 | UiTreeEventData *event = ui_malloc(obj->ctx, sizeof(UiTreeEventData)); |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
90 | event->obj = obj; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
91 | event->activate = modelinfo->activate; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
92 | event->selection = modelinfo->selection; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
93 | event->userdata = modelinfo->userdata; |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
94 | event->last_selection = NULL; |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
95 | if(modelinfo->selection) { |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
96 | XtAddCallback( |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
97 | container, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
98 | XmNselectionCallback, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
99 | (XtCallbackProc)ui_table_select_callback, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
100 | event); |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
101 | } |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
102 | if(modelinfo->activate) { |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
103 | XtAddCallback( |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
104 | container, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
105 | XmNdefaultActionCallback, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
106 | (XtCallbackProc)ui_table_action_callback, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
107 | event); |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
108 | } |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
109 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | // add initial data |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | void *data = model->first(model); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
112 | int width = 0; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | while(data) { |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
114 | int w = ui_add_icon_gadget(container, modelinfo, data); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
115 | if(w > width) { |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
116 | width = w; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
117 | } |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | data = model->next(model); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
121 | // set new XmContainer width |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
122 | XtVaSetValues(container, XmNwidth, width, NULL); |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
123 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | // cleanup |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | for(int i=0;i<modelinfo->columns;i++) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | XmStringFree(header[i]); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | XtFree((char*)header); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
130 | return scrollw; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
133 | #define UI_COL_CHAR_WIDTH 12 |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
134 | |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
135 | int ui_add_icon_gadget(Widget container, UiModelInfo *modelinfo, void *data) { |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
136 | int width = 50; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
137 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | if(modelinfo->columns == 0) { |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
139 | return width; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | XmString label = NULL; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | Arg args[8]; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | Boolean f; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | // first column |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | if(modelinfo->types[0] != 12345678) { // TODO: icon/label type |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | char *str = ui_type_to_string( |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | modelinfo->types[0], |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | modelinfo->getvalue(data, 0), |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | &f); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
151 | |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
152 | // column width |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
153 | width += strlen(str) * UI_COL_CHAR_WIDTH; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
154 | |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
155 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | XmString label = XmStringCreateLocalized(str); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | XtSetArg(args[0], XmNlabelString, label); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | if(f) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | free(str); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | } else { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | // TODO |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | // remaining columns are the icon gadget details |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | XmStringTable details = (XmStringTable)XtMalloc( |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | (modelinfo->columns - 1) * sizeof(XmString)); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | for(int i=1;i<modelinfo->columns;i++) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | char *str = ui_type_to_string( |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | modelinfo->types[i], |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | modelinfo->getvalue(data, i), |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | &f); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
173 | |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
174 | // column width |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
175 | width += strlen(str) * UI_COL_CHAR_WIDTH; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
176 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | details[i - 1] = XmStringCreateLocalized(str); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | if(f) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | free(str); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | XtSetArg(args[1], XmNdetail, details); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | XtSetArg(args[2], XmNdetailCount, modelinfo->columns - 1); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
184 | XtSetArg(args[3], XmNshadowThickness, 0); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | // create widget |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
186 | Widget item = XmCreateIconGadget(container, "table_item", args, 4); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | XtManageChild(item); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | // cleanup |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | XmStringFree(label); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | for(int i=0;i<modelinfo->columns-1;i++) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | XmStringFree(details[i]); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | XtFree((char*)details); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
195 | |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
196 | return width; |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | char* ui_type_to_string(UiModelType type, void *data, Boolean *free) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | switch(type) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | case UI_STRING: *free = FALSE; return data; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | case UI_INTEGER: { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | *free = TRUE; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | int *val = data; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | sstr_t str = ucx_asprintf(ucx_default_allocator(), "%d", *val); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | return str.ptr; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | *free = FALSE; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | return NULL; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | } |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
212 | |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
213 | void ui_table_action_callback( |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
214 | Widget widget, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
215 | UiTreeEventData *event, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
216 | XmContainerSelectCallbackStruct *sel) |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
217 | { |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
218 | UiListSelection *selection = ui_list_selection(sel); |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
219 | |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
220 | UiEvent e; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
221 | e.obj = event->obj; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
222 | e.window = event->obj->window; |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
223 | e.document = event->obj->ctx->document; |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
224 | e.eventdata = selection; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
225 | e.intval = selection->count > 0 ? selection->rows[0] : -1; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
226 | event->activate(&e, event->userdata); |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
227 | |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
228 | free(event->last_selection->rows); |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
229 | free(event->last_selection); |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
230 | event->last_selection = selection; |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
231 | } |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
232 | |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
233 | void ui_table_select_callback( |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
234 | Widget widget, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
235 | UiTreeEventData *event, |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
236 | XmContainerSelectCallbackStruct *sel) |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
237 | { |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
238 | UiListSelection *selection = ui_list_selection(sel); |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
239 | if(!ui_compare_list_selection(selection, event->last_selection)) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
240 | UiEvent e; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
241 | e.obj = event->obj; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
242 | e.window = event->obj->window; |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
243 | e.document = event->obj->ctx->document; |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
244 | e.eventdata = selection; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
245 | e.intval = selection->count > 0 ? selection->rows[0] : -1; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
246 | event->selection(&e, event->userdata); |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
247 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
248 | if(event->last_selection) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
249 | free(event->last_selection->rows); |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
250 | free(event->last_selection); |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
251 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
252 | event->last_selection = selection; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
253 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
254 | |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
255 | UiListSelection* ui_list_selection(XmContainerSelectCallbackStruct *xs) { |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
256 | UiListSelection *selection = malloc(sizeof(UiListSelection)); |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
257 | selection->count = xs->selected_item_count; |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
258 | selection->rows = calloc(selection->count, sizeof(int)); |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
259 | for(int i=0;i<selection->count;i++) { |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
260 | int index; |
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
261 | XtVaGetValues(xs->selected_items[i], XmNpositionIndex, &index, NULL); |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
262 | selection->rows[i] = index; |
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
263 | } |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
264 | return selection; |
43
157a21a914ac
added table view events (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
265 | } |
44
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
266 | |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
267 | Boolean ui_compare_list_selection(UiListSelection *s1, UiListSelection *s2) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
268 | if(!s1 || !s2) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
269 | return FALSE; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
270 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
271 | if(s1->count != s2->count) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
272 | return FALSE; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
273 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
274 | for(int i=0;i<s1->count;i++) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
275 | if(s1->rows[i] != s2->rows[i]) { |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
276 | return FALSE; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
277 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
278 | } |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
279 | return TRUE; |
a1571777eff2
optimized selection callback (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
280 | } |