ui/motif/container.c

Fri, 16 May 2014 19:20:17 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 16 May 2014 19:20:17 +0200
changeset 44
a1571777eff2
parent 36
e4198fc2ead4
child 52
25e5390cce41
permissions
-rw-r--r--

optimized selection callback (Motif)

4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
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>
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "container.h"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "../common/context.h"
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
34 #include "../common/object.h"
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 UiContainer* ui_frame_container(UiObject *obj, Widget frame) {
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 UiContainer *ct = ucx_mempool_malloc(
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 obj->ctx->mempool,
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 sizeof(UiContainer));
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 ct->widget = frame;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 ct->add = ui_frame_container_add;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 return ct;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 }
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 Widget ui_frame_container_add(UiContainer *ct, Arg *args, int *n) {
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 return ct->widget;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 }
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
48
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
49
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
50 UIWIDGET ui_sidebar(UiObject *obj) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
51 UiContainer *ct = uic_get_current_container(obj);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
52
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
53 Arg args[8];
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
54 int n = 0;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
55 XtSetArg(args[n], XmNorientation, XmHORIZONTAL);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
56 n++;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
57
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
58 Widget parent = ct->add(ct, args, &n);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
59 Widget pane = XmCreatePanedWindow(parent, "pane", args, n);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
60 XtManageChild(pane);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
61
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
62 // add sidebar widget
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
63 XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
64 XtSetArg(args[1], XmNshadowThickness, 0);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
65 Widget sidebar = XmCreateFrame(pane, "sidebar", args, 2);
36
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
66 XtManageChild(sidebar);
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
67
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
68 UiObject *left = uic_object_new(obj, sidebar);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
69 left->container = ui_frame_container(left, sidebar);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
70
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
71 // add content widget
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
72 XtSetArg (args[2], XmNpaneMaximum, 8000);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
73 Widget content = XmCreateFrame(pane, "content_area", args, 3);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
74 XtManageChild(content);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
75
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
76 UiObject *right = uic_object_new(obj, content);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
77 right->container = ui_frame_container(right, content);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
78
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
79 uic_obj_add(obj, right);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
80 uic_obj_add(obj, left);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
81
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
82 return sidebar;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
83 }

mercurial