2 * Copyright 2022 Olaf Wintermann
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
31 static void sidebar_class_init(void);
32 static void sidebar_class_part_init (WidgetClass wc);
33 static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *num_args);
34 static void sidebar_destroy(Widget widget);
35 static void sidebar_resize(Widget widget);
36 static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes);
37 static void sidebar_expose(Widget widget, XEvent *event, Region region);
38 static Boolean sidebar_set_values(Widget old, Widget request, Widget neww, ArgList args, Cardinal *num_args);
39 static void sidebar_insert_child(Widget child);
40 Boolean sidebar_acceptfocus(Widget widget, Time *time);
41 static void FocusInAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
44 static XtResource resources[] = {
48 static XtActionsRec actionslist[] = {
49 {"focusIn", FocusInAP},
53 static char defaultTranslations[] = "<FocusIn>: focusIn()";
56 static XtResource constraints[] = {};
58 SidebarClassRec sidebarWidgetClassRec = {
61 (WidgetClass)&xmManagerClassRec,
62 "XnSidebar", // class_name
63 sizeof(SidebarRec), // widget_size
64 sidebar_class_init, // class_initialize
65 sidebar_class_part_init, // class_part_initialize
66 FALSE, // class_inited
67 sidebar_init, // initialize
68 NULL, // initialize_hook
69 sidebar_realize, // realize
70 actionslist, // actions
71 XtNumber(actionslist), // num_actions
72 resources, // resources
73 XtNumber(resources), // num_resources
74 NULLQUARK, // xrm_class
75 True, // compress_motion
76 True, // compress_exposure
77 True, // compress_enterleave
78 False, // visible_interest
79 sidebar_destroy, // destroy
80 sidebar_resize, // resize
81 sidebar_expose, // expose
82 sidebar_set_values, // set_values
83 NULL, // set_values_hook
84 XtInheritSetValuesAlmost, // set_values_almost
85 NULL, // get_values_hook
86 sidebar_acceptfocus, // accept_focus
88 NULL, // callback_offsets
89 defaultTranslations, // tm_table
90 XtInheritQueryGeometry, // query_geometry
91 XtInheritDisplayAccelerator, // display_accelerator
96 XtInheritGeometryManager, // geometry_manager
97 XtInheritChangeManaged, // change_managed
98 sidebar_insert_child, // insert_child
99 XtInheritDeleteChild, // delete_child
104 constraints, // resources
105 XtNumber(constraints), // num_resources
106 sizeof(XmFormConstraintRec), // constraint_size
114 XtInheritTranslations, // translations
115 NULL, // syn_resources
116 0, // num_syn_resources
117 NULL, // syn_constraint_resources
118 0, // num_syn_constraint_resources
119 XmInheritParentProcess, // parent_process
128 WidgetClass xnSidebarWidgetClass = (WidgetClass)&sidebarWidgetClassRec;
131 static void sidebar_class_init(void) {
135 static void sidebar_class_part_init (WidgetClass wc) {
136 SidebarClassRec *sidebarClass = (SidebarClassRec*)wc;
137 XmManagerClassRec *managerClass = (XmManagerClassRec*)xmManagerWidgetClass;
139 sidebarClass->constraint_class.initialize = managerClass->constraint_class.initialize;
140 sidebarClass->constraint_class.set_values = managerClass->constraint_class.set_values;
145 static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *num_args) {
151 static void sidebar_destroy(Widget widget) {
155 static void sidebar_resize(Widget widget) {
159 static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes) {
160 (xmManagerClassRec.core_class.realize)(widget, mask, attributes);
165 static void sidebar_expose(Widget widget, XEvent *event, Region region) {
168 XtMakeResizeRequest(widget, 200, 200, &w, &h);
171 static Boolean sidebar_set_values(Widget old, Widget request, Widget neww, ArgList args, Cardinal *num_args) {
177 static void sidebar_insert_child(Widget child) {
178 (xmManagerClassRec.composite_class.insert_child)(child);
181 Boolean sidebar_acceptfocus(Widget widget, Time *time) {
186 static void FocusInAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) {
192 /* --------------------------- public --------------------------- */
194 Widget CreateSidebar(
200 return XtCreateWidget(name, xnSidebarWidgetClass, parent, arglist, argcount);