#ifndef XMTREE_H_ #define XMTREE_H_ #include#include #include /* toggles arrow direction */ void arrowCB(Widget arrow, XtPointer clientData, XtPointer callData); /* */ void nodeCB(Widget node, XtPointer clientData, XtPointer callData); /* */ void createNode(String caption, Widget tree, int left, int top); /* */ void createSubNode(String caption, Widget tree, int left, int top); /* plain old right arrow button */ Widget createArrowButton(int left, int top, Widget tree); /* */ Widget createNodeButton(String caption, Widget tree, int left, int top); /* parent is fraTreeScrolledWindow */ void loadTree(Widget parent); #endif /* XMTREE_H_ */ /* * xmTree.c * * Created on: Apr 14, 2017 * Author: chuck */ #include "xmTree.h" /* toggles arrow direction */ void arrowCB(Widget arrow, XtPointer clientData, XtPointer callData) { unsigned char direction; XtVaGetValues(arrow, XmNarrowDirection, &direction, NULL); if(direction == XmARROW_RIGHT) { XtVaSetValues(arrow, XmNarrowDirection, XmARROW_DOWN, NULL); } if(direction == XmARROW_DOWN) { XtVaSetValues(arrow, XmNarrowDirection, XmARROW_RIGHT, NULL); } } /* */ void nodeCB(Widget node, XtPointer clientData, XtPointer callData) { // printf("node call back\n"); XmPushButtonCallbackStruct *cbs = (XmPushButtonCallbackStruct *)callData; // } /* plain old right arrow button */ Widget createArrowButton(int left, int top, Widget tree) { // Widget arrow = XtVaCreateManagedWidget("arrow", xmArrowButtonWidgetClass, tree, XmNarrowDirection, XmARROW_RIGHT, XmNx, left, XmNy, top, XmNbackground, 0, XmNshadowThickness, 0, NULL); XtAddCallback(arrow, XmNactivateCallback, arrowCB, NULL); return arrow; } /* */ Widget createNodeButton(String caption, Widget tree, int left, int top) { // Widget nodeButton = XtVaCreateManagedWidget(caption, xmPushButtonWidgetClass, tree, XmNx, left, XmNy, top, XmNbackground, 0, XmNshadowThickness, 0, NULL); XtAddCallback(nodeButton, XmNactivateCallback, nodeCB, NULL); return nodeButton; } /* with children */ void createNode(String caption, Widget tree, int left, int top) { Widget arrow = createArrowButton(left, top, tree); Widget node = createNodeButton(caption, tree, left + 25, top); } /* without children */ void createSubNode(String caption, Widget tree, int left, int top) { Widget node = createNodeButton(caption, tree, left + 10, top); } /**** this might be like phpPGAdmin ****/ /* parent is fraTreeScrolledWindow */ void loadTree(Widget parent) { Widget tree = XtVaCreateManagedWidget("tree", xmFormWidgetClass, parent, XmNbackground, 0, XmNwidth, 640, XmNheight, 1024, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomWidget, XmATTACH_FORM, NULL); printf("from load tree\n"); //createNode(caption, tree, x, y); createNode("PostgreSQL", tree, 0, 0); createNode("init_main", tree, 25, 25); createNode("tables", tree, 50, 50); createNode("doe", tree, 75, 75); createNode("cols", tree, 100, 100); //createSubNode(String caption, Widget tree, int left, int top); createSubNode("d_id", tree, 125, 125); createSubNode("d_l", tree, 125, 150); createSubNode("d_nm", tree, 125, 175); createSubNode("d_val", tree, 125, 200); createSubNode("d_t", tree, 125, 225); createNode("moe", tree, 75, 250); createNode("noe", tree, 75, 275); }