.
.
.
/* Svn Attach Callback */
(1)static void svn_attach_proc(svnw)
Widget svnw;
{
/*
** Local data declarations
*/
unsigned int entry_tags [1];
/*
** Announce the routine on the debugging terminal
*/
printf ("AttachToSource handler\n");
/*
** Initialize the book data structure
*/
LclInitializeList ();
/*
** Make room for the books entries. I will pass the tag array here since I
** know that I have exactly one entry and it's easy to figure out the tag.
*/
entry_tags[0] = (unsigned int) &B;
DXmSvnAddEntries (svnw, 0, 1, 0, entry_tags, TRUE);
/*
** Reflect this addition in the global count.
*/
SourceNumEntries = 1;
}
/*
** SelectAndConfirm callback routine. This routine is called when one and
** only one Entry is selected. The Entry number selected is provided in the
** callback structure.
*/
(2)static void svn_confirm_proc(w, unused_tag, data)
Widget w;
int unused_tag;
DXmSvnCallbackStruct *data;
{
/*
** Announce the routine on the debugging terminal
*/
printf ("SelectAndConfirm handler\n");
/*
** Determine if the Entry can be expanded. If so, then tell the source module
** to deal with it.
*/
if (SourceIsNodeParent (data->entry_number, data->entry_tag) == TRUE)
{
SourceToggleNode (data->entry_number, data->entry_tag);
DXmSvnClearSelection (w, data->entry_number);
};
}
/*
** This routine is called when the widget wants the Source module to set
** the information associated with a particular entry.
*/
(3)static void svn_get_entry_proc(svnw, unused_tag, data)
Widget svnw;
int unused_tag;
DXmSvnCallbackStruct *data;
{
/*
** Local data declarations
*/
int i;
NodePtr node;
Arg args[10];
XmFontList fontlist;
fontlist = XmFontListCreate (XLoadQueryFont (XtDisplay(toplevel),
"*helvetica-medium-r-*-14-*"), XmSTRING_DEFAULT_CHARSET);
/*
** Announce the routine on the debugging terminal
*/
printf ("GetEntry handler - entry_number = %d, entry_tag = %d\n",
data->entry_number, data->entry_tag);
/*
** Get at the node (if needed)
*/
if (data->entry_tag == 0)
node = LclGetNodePtr (data->entry_number);
else node = (NodePtr) data->entry_tag;
/*
** Set up the pixmaps
*/
LclSetUpPixmap (svnw);
/*
** Set the entry information that both children and parent nodes
** have in common.
*/
DXmSvnSetEntryNumComponents (svnw, data->entry_number, SourceNumComps);
DXmSvnSetEntryTag (svnw, data->entry_number, node);
/*
* The first component is different in parent/child nodes and always present.
* If there are no children, use the child pixmap. Otherwise use the parent
* pixmap.
*/
if (node->number == 0)
DXmSvnSetComponentPixmap (svnw, data->entry_number, 1, 0, 0,
child_pixmap, pixmap_width, pixmap_height);
else DXmSvnSetComponentPixmap (svnw, data->entry_number, 1, 0, 0,
parent_pixmap, pixmap_width, pixmap_height);
(4)DXmSvnSetComponentText (svnw, data->entry_number, 2, pixmap_width+4,
0, node->text, fontlist);
}
/*
** Global routine that opens a closed node or closes an open node.
*/
void SourceToggleNode (node_number, entry_tag)
int node_number;
unsigned int entry_tag;
{
/*
** Local data declarations
*/
NodePtr node;
/*
** Get at the node (if needed)
*/
if (entry_tag == 0)
node = LclGetNodePtr (node_number);
else node = (NodePtr) entry_tag;
/*
** If it is opened, then close it. Otherwise open it.
*/
if (node->opened == TRUE)
SourceCloseNode (node_number, entry_tag);
else SourceOpenNode (node_number, entry_tag);
}
/*
** Global routine that tells the caller if the given node has child nodes.
*/
Boolean SourceIsNodeParent (node_number, entry_tag)
int node_number;
unsigned int entry_tag;
{
/*
** Local data declarations
*/
NodePtr node;
/*
** Get at the node (if needed)
*/
if (entry_tag == 0)
node = LclGetNodePtr (node_number);
else node = (NodePtr) entry_tag;
/*
** Return TRUE or FALSE
*/
if (node->children == 0)
return FALSE;
else return TRUE;
}
/*
** Global routine that opens a node, given the node number
*/
static void SourceOpenNode(node_number, entry_tag)
int node_number;
unsigned int entry_tag;
{
/*
** Local data declarations
*/
NodePtr node;
NodePtr child_node;
int i, x, y;
/*
** Get at the node (if needed)
*/
if (entry_tag == 0)
node = LclGetNodePtr (node_number);
else node = (NodePtr) entry_tag;
/*
** If it is already opened, then return.
*/
if (node->opened == TRUE)
return;
/*
** If it has no children, then return.
*/
if (node->number == 0)
return;
/*
** Mark the node as being opened
*/
node->opened = TRUE;
/*
* Add the entries. This code does not yet use the entry_tags array.
*/
DXmSvnAddEntries (svn_widget, node_number, node->number,
node->level, NULL, FALSE);
/*
* Get to the first child of this node
*/
child_node = node->children;
/*
* For each child, call SetEntry if the child has children. Also set their
* positions in case we have a UserDefined Tree Style.
*/
DXmSvnGetEntryPosition(svn_widget, node_number, FALSE, &x, &y);
for (i = 1; i <= node->number; i++)
{
if (child_node->children != 0)
DXmSvnSetEntry (svn_widget, node_number+i, 0, 0, 2, 1, 0, FALSE);
child_node = child_node->sibling;
x += 30;
y += 30;
DXmSvnSetEntryPosition(svn_widget, node_number+i, FALSE, x, y);
};
/*
** Reflect this addition in the global count.
*/
SourceNumEntries = SourceNumEntries + node->number;
}
/*
** Global routine that closes a node, given the node number
*/
void SourceCloseNode (node_number, entry_tag)
int node_number;
unsigned int entry_tag;
{
/*
** Local data declarations
*/
NodePtr node;
/*
** Get at the node (if needed)
*/
if (entry_tag == 0)
node = LclGetNodePtr (node_number);
else node = (NodePtr) entry_tag;
/*
** Call the local recursive close routine.
*/
LclCloseNode(node, node_number);
}
/*
** Recursively close all nodes given a current node pointer
** and a current node number.
*/
void LclCloseNode(node, node_number)
NodePtr node;
int node_number;
{
/*
** Local data declarations
*/
int i;
NodePtr child_node;
/*
** If the current node is not opened, then return
*/
if (node->opened == FALSE)
return;
/*
** Get to the first child of this node
*/
child_node = node->children;
/*
** For each child, call CloseNode on each child
*/
for (i=1; i<=node->number; i++)
{
LclCloseNode (child_node, node_number);
child_node = child_node->sibling;
};
/*
** Tell SVN to remove its children
*/
DXmSvnDeleteEntries (svn_widget, node_number, node->number);
/*
** Mark the node closed
*/
node->opened = FALSE;
if (node->stext != NULL) XtUnmanageChild(node->stext);
/*
** Reflect this removal in the global count.
*/
SourceNumEntries = SourceNumEntries - node->number;
}
/*
** Routine that maps a node_number into a node structure pointer.
*/
NodePtr LclGetNodePtr (node_number)
int node_number;
{
/*
** Local routine data
*/
int i;
NodePtr current_node = &B;
/*
** Loop through until it's found. If we hit the end of the list, then
** we'll return a null pointer.
*/
if (node_number != 1)
for (i = 2; i <= node_number; i++)
if (current_node == NULL)
break;
else if (current_node->opened)
current_node = current_node->children;
else current_node = current_node->sibling;
/*
** Return the node address
*/
return current_node;
}
.
.
.
|