+/*
+ * Copyright 2022 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "Sidebar.h"
+#include "SidebarP.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void sidebar_class_init(void);
+static void sidebar_class_part_init (WidgetClass wc);
+static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *num_args);
+static void sidebar_destroy(Widget widget);
+static void sidebar_resize(Widget widget);
+static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes);
+static void sidebar_expose(Widget widget, XEvent *event, Region region);
+static Boolean sidebar_set_values(Widget old, Widget request, Widget neww, ArgList args, Cardinal *num_args);
+static void sidebar_insert_child(Widget child);
+Boolean sidebar_acceptfocus(Widget widget, Time *time);
+static void FocusInAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
+
+
+static XtResource resources[] = {
+
+};
+
+static XtActionsRec actionslist[] = {
+ {"focusIn", FocusInAP},
+ {"NULL", NULL}
+};
+
+static char defaultTranslations[] = "<FocusIn>: focusIn()";
+
+
+static XtResource constraints[] = {};
+
+SidebarClassRec sidebarWidgetClassRec = {
+ // Core Class
+ {
+ (WidgetClass)&xmManagerClassRec,
+ "XnSidebar", // class_name
+ sizeof(SidebarRec), // widget_size
+ sidebar_class_init, // class_initialize
+ sidebar_class_part_init, // class_part_initialize
+ FALSE, // class_inited
+ sidebar_init, // initialize
+ NULL, // initialize_hook
+ sidebar_realize, // realize
+ actionslist, // actions
+ XtNumber(actionslist), // num_actions
+ resources, // resources
+ XtNumber(resources), // num_resources
+ NULLQUARK, // xrm_class
+ True, // compress_motion
+ True, // compress_exposure
+ True, // compress_enterleave
+ False, // visible_interest
+ sidebar_destroy, // destroy
+ sidebar_resize, // resize
+ sidebar_expose, // expose
+ sidebar_set_values, // set_values
+ NULL, // set_values_hook
+ XtInheritSetValuesAlmost, // set_values_almost
+ NULL, // get_values_hook
+ sidebar_acceptfocus, // accept_focus
+ XtVersion, // version
+ NULL, // callback_offsets
+ defaultTranslations, // tm_table
+ XtInheritQueryGeometry, // query_geometry
+ XtInheritDisplayAccelerator, // display_accelerator
+ NULL, // extension
+ },
+ // Composite Class
+ {
+ XtInheritGeometryManager, // geometry_manager
+ XtInheritChangeManaged, // change_managed
+ sidebar_insert_child, // insert_child
+ XtInheritDeleteChild, // delete_child
+ NULL, // extension
+ },
+ // Constraint Class
+ {
+ constraints, // resources
+ XtNumber(constraints), // num_resources
+ sizeof(XmFormConstraintRec), // constraint_size
+ NULL, // initialize
+ NULL, // destroy
+ NULL, // set_value
+ NULL, // extension
+ },
+ // XmManager Class
+ {
+ XtInheritTranslations, // translations
+ NULL, // syn_resources
+ 0, // num_syn_resources
+ NULL, // syn_constraint_resources
+ 0, // num_syn_constraint_resources
+ XmInheritParentProcess, // parent_process
+ NULL // extension
+ },
+ // Sidebar Class
+ {
+ 0
+ }
+};
+
+WidgetClass xnSidebarWidgetClass = (WidgetClass)&sidebarWidgetClassRec;
+
+
+static void sidebar_class_init(void) {
+
+}
+
+static void sidebar_class_part_init (WidgetClass wc) {
+ SidebarClassRec *sidebarClass = (SidebarClassRec*)wc;
+ XmManagerClassRec *managerClass = (XmManagerClassRec*)xmManagerWidgetClass;
+
+ sidebarClass->constraint_class.initialize = managerClass->constraint_class.initialize;
+ sidebarClass->constraint_class.set_values = managerClass->constraint_class.set_values;
+}
+
+
+
+static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *num_args) {
+
+}
+
+
+
+static void sidebar_destroy(Widget widget) {
+
+}
+
+static void sidebar_resize(Widget widget) {
+
+}
+
+static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes) {
+ (xmManagerClassRec.core_class.realize)(widget, mask, attributes);
+
+
+}
+
+static void sidebar_expose(Widget widget, XEvent *event, Region region) {
+ printf("expose\n");
+ Dimension w, h;
+ XtMakeResizeRequest(widget, 200, 200, &w, &h);
+}
+
+static Boolean sidebar_set_values(Widget old, Widget request, Widget neww, ArgList args, Cardinal *num_args) {
+ Boolean r = False;
+
+ return r;
+}
+
+static void sidebar_insert_child(Widget child) {
+ (xmManagerClassRec.composite_class.insert_child)(child);
+}
+
+Boolean sidebar_acceptfocus(Widget widget, Time *time) {
+ return 0;
+}
+
+
+static void FocusInAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) {
+
+}
+
+
+
+/* --------------------------- public --------------------------- */
+
+Widget CreateSidebar(
+ Widget parent,
+ String name,
+ ArgList arglist,
+ Cardinal argcount)
+{
+ return XtCreateWidget(name, xnSidebarWidgetClass, parent, arglist, argcount);
+}