diff options
-rw-r--r-- | src/bltGrAxis.h | 1 | ||||
-rw-r--r-- | src/bltGrBind.C | 41 | ||||
-rw-r--r-- | src/bltGraph.C | 62 |
3 files changed, 60 insertions, 44 deletions
diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index 4aec392..a98a936 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -221,6 +221,7 @@ class Axis { Tk_OptionTable optionTable() {return optionTable_;} void* ops() {return ops_;} ClassId classId() {return classId_;} + const char* className() {return className_;} int configure(); void map(int, int); diff --git a/src/bltGrBind.C b/src/bltGrBind.C index 4a41838..ad4c09e 100644 --- a/src/bltGrBind.C +++ b/src/bltGrBind.C @@ -29,6 +29,11 @@ #include <stdlib.h> +#include <iostream> +#include <sstream> +#include <iomanip> +using namespace std; + extern "C" { #include "bltBind.h" }; @@ -54,7 +59,7 @@ typedef struct _Blt_BindTable BindTable; LeaveWindowMask | KeyPressMask | KeyReleaseMask | \ PointerMotionMask | VirtualEventMask) - static int buttonMasks[] = {0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask}; +static int buttonMasks[] = {0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask}; static void DoEvent(BindTable* bindPtr, XEvent* eventPtr, ClientData item, ClientData context) @@ -69,35 +74,13 @@ static void DoEvent(BindTable* bindPtr, XEvent* eventPtr, if (!item) return; - // Invoke the binding system. - Blt_List tagList = Blt_List_Create(BLT_ONE_WORD_KEYS); - if (!bindPtr->tagProc) { - Blt_List_Append(tagList, Tk_GetUid("all"), 0); - Blt_List_Append(tagList, (char*)item, 0); - } - else - (*bindPtr->tagProc)(bindPtr, item, context, tagList); - - if (Blt_List_GetLength(tagList) > 0) { - ClientData staticTags[MAX_STATIC_TAGS]; - ClientData *tagArray = staticTags; - int nTags = Blt_List_GetLength(tagList); - if (nTags >= MAX_STATIC_TAGS) - tagArray = (ClientData*)malloc(sizeof(ClientData) * nTags); - - nTags = 0; - for (Blt_ListNode node = Blt_List_FirstNode(tagList); node; - node = Blt_List_NextNode(node)) - tagArray[nTags++] = (ClientData)Blt_List_GetKey(node); - - Tk_BindEvent(bindPtr->bindingTable, eventPtr, bindPtr->tkwin, nTags, - tagArray); - - if (tagArray != staticTags) - free(tagArray); - } + int nTags; + const char** tagArray = (*bindPtr->tagProc)(bindPtr, item, context, &nTags); + Tk_BindEvent(bindPtr->bindingTable, eventPtr, bindPtr->tkwin, nTags, + (void**)tagArray); - Blt_List_Destroy(tagList); + if (tagArray) + delete [] tagArray; } static void PickCurrentItem(BindTable *bindPtr, XEvent *eventPtr) diff --git a/src/bltGraph.C b/src/bltGraph.C index 0e9fd7a..b54291e 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -30,7 +30,6 @@ #include <float.h> extern "C" { -#include "bltList.h" #include "bltBind.h" }; @@ -1266,33 +1265,54 @@ Axis* Graph::nearestAxis(int x, int y) return NULL; } -void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context, - Blt_List list) +const char** Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context, int* num) { Graph* graphPtr = (Graph*)table->clientData; ClassId classId = (ClassId)(long(context)); + const char** tags =NULL; + switch (classId) { case CID_ELEM_BAR: case CID_ELEM_LINE: { Element* ptr = (Element*)object; - Blt_List_Append(list,(const char*)graphPtr->elementTag(ptr->name_),0); - Blt_List_Append(list,(const char*)graphPtr->elementTag(ptr->className()),0); ElementOptions* ops = (ElementOptions*)ptr->ops(); - for (const char** pp = ops->tags; *pp; pp++) - Blt_List_Append(list, (const char*)graphPtr->elementTag(*pp),0); + int cnt =0; + for (const char** pp=ops->tags; *pp; pp++) + cnt++; + cnt +=2; + + tags = new const char*[cnt]; + tags[0] = (const char*)graphPtr->elementTag(ptr->name_); + tags[1] = (const char*)graphPtr->elementTag(ptr->className()); + int ii=2; + for (const char** pp = ops->tags; *pp; pp++, ii++) + tags[ii] = (const char*)graphPtr->elementTag(*pp); + + *num = cnt; + return tags; } break; case CID_AXIS_X: case CID_AXIS_Y: { Axis* ptr = (Axis*)object; - Blt_List_Append(list,(const char*)graphPtr->axisTag(ptr->name_),0); - Blt_List_Append(list,(const char*)graphPtr->axisTag(ptr->className_),0); AxisOptions* ops = (AxisOptions*)ptr->ops(); - for (const char** pp = ops->tags; *pp; pp++) - Blt_List_Append(list, (const char*)graphPtr->axisTag(*pp),0); + int cnt =0; + for (const char** pp=ops->tags; *pp; pp++) + cnt++; + cnt +=2; + + tags = new const char*[cnt]; + tags[0] = (const char*)graphPtr->axisTag(ptr->name_); + tags[1] = (const char*)graphPtr->axisTag(ptr->className()); + int ii=2; + for (const char** pp = ops->tags; *pp; pp++, ii++) + tags[ii] = (const char*)graphPtr->axisTag(*pp); + + *num = cnt; + return tags; } break; case CID_MARKER_BITMAP: @@ -1301,16 +1321,28 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context, case CID_MARKER_TEXT: { Marker* ptr = (Marker*)object; - Blt_List_Append(list,(const char*)graphPtr->markerTag(ptr->name_),0); - Blt_List_Append(list,(const char*)graphPtr->markerTag(ptr->className()),0); MarkerOptions* ops = (MarkerOptions*)ptr->ops(); - for (const char** pp = ops->tags; *pp; pp++) - Blt_List_Append(list, (const char*)graphPtr->markerTag(*pp),0); + int cnt =0; + for (const char** pp=ops->tags; *pp; pp++) + cnt++; + cnt +=2; + + tags = new const char*[cnt]; + tags[0] = (const char*)graphPtr->markerTag(ptr->name_); + tags[1] = (const char*)graphPtr->markerTag(ptr->className()); + int ii=2; + for (const char** pp = ops->tags; *pp; pp++, ii++) + tags[ii] = (const char*)graphPtr->markerTag(*pp); + + *num = cnt; + return tags; } break; default: break; } + + return NULL; } // Find the closest point from the set of displayed elements, searching |