Widget CRemoveFieldAction::GetAttributesArea(Widget parent, symbolPtr* pSym){ XmString labelStr; Widget area = XtVaCreateWidget("area", xmFormWidgetClass, parent, XmNwidth, 300, XmNheight, 30, XmNnumColumns, 2, XmNpacking, XmPACK_COLUMN, XmNorientation, XmVERTICAL, NULL); string result; string command; string id = prepareQuery(CEntityInfo::etag(pSym)); setWait(true); CEntityInfo::exec("printformat \"%s\t%s\" cname etag",result); if(CEntityInfo::language(pSym).compare("JAVA")) // For Java we also need to retrieve static fields ("uses -var")! command = string("sort [set_subtract [set_union [get_member_data ") + id + string("] [uses -var ") + id + string("]] [set_copy ") + id + string("]]"); else command = string("sort [set_subtract [get_member_data ") + id + string("] [set_copy ") + id + string("]]"); CEntityInfo::exec(command,result); m_pFields = new CQueryResult(); m_pFields->parse(result); if(m_pFields->getRecordsCount()>0) { // if we have something to remove - display it labelStr = XmStringCreateLocalized("Field:"); Widget labelWidget = XtVaCreateManagedWidget("label_1",xmLabelGadgetClass, area, XmNlabelString, labelStr, XmNwidth, 100, XmNtopAttachment,XmATTACH_FORM, XmNleftAttachment,XmATTACH_FORM, XmNbottomAttachment,XmATTACH_FORM, NULL); XmStringFree(labelStr); m_FieldsList = XtVaCreateManagedWidget("fieldslist", dtComboBoxWidgetClass, area, XmNtopAttachment,XmATTACH_FORM, XmNleftAttachment,XmATTACH_WIDGET, XmNleftWidget, labelWidget, XmNrightAttachment,XmATTACH_FORM, XmNbottomAttachment,XmATTACH_FORM, NULL); TRecordSetIterator iter = m_pFields->getStartRecord(); TRecordSetIterator end = m_pFields->getEndRecord(); while(iter!=end) { TRecord* pRecord = *iter; labelStr = XmStringCreateLocalized((char*)(*pRecord)[1]->c_str()); DtComboBoxAddItem(m_FieldsList, labelStr, 0, false); XmStringFree(labelStr); iter++; } } else { // otherwise display a message labelStr = XmStringCreateLocalized("Nothing to remove."); Widget labelWidget = XtVaCreateManagedWidget("label_1",xmLabelGadgetClass, area, XmNlabelString, labelStr, XmNwidth, 100, XmNtopAttachment,XmATTACH_FORM, XmNleftAttachment,XmATTACH_FORM, XmNbottomAttachment,XmATTACH_FORM, XmNrightAttachment,XmATTACH_FORM, NULL); XmStringFree(labelStr); } setWait(false); return area; }
static void CreateComboBoxes(Widget parent) { Widget titleLabel, comboBox, list; XmString *valueXmstrings, *colorXmstrings; int numValueStrings, numColorStrings; XmString labelString, xmString; Arg args[20]; int i, n; /* Create value compound strings */ numValueStrings = XtNumber(comboValueStrings); valueXmstrings = (XmString *)XtMalloc(numValueStrings * sizeof(XmString*)); for (i = 0; i < numValueStrings; i++) { valueXmstrings[i] = XmStringCreateLocalized(comboValueStrings[i]); } /* Create color compound strings */ numColorStrings = XtNumber(colorStrings); colorXmstrings = (XmString *)XtMalloc(numColorStrings * sizeof(XmString*)); for (i = 0; i < numColorStrings; i++) { colorXmstrings[i] = XmStringCreateLocalized(colorStrings[i]); } /* Create title label */ labelString = XmStringCreateLocalized("ComboBox Widget"); n = 0; XtSetArg(args[n], XmNlabelString, labelString); n++; titleLabel = XmCreateLabel(parent, "title", args, n); XtManageChild(titleLabel); XmStringFree(labelString); /* * Create an editable ComboBox containing the color strings. * Get the widget id of the drop down list, add some greek * letter names to it, and make more items visible. */ n = 0; XtSetArg(args[n], DtNcomboBoxType, DtDROP_DOWN_COMBO_BOX); n++; XtSetArg(args[n], DtNitems, colorXmstrings); n++; XtSetArg(args[n], DtNitemCount, numColorStrings); n++; XtSetArg(args[n], DtNvisibleItemCount, 5); n++; XtSetArg(args[n], DtNcolumns, 10); n++; comboBox = DtCreateComboBox(parent, "comboBox1", args, n); XtManageChild(comboBox); list = XtNameToWidget(comboBox, "*List"); XmListAddItems(list, valueXmstrings, 10, 0); XtVaSetValues(list, XmNvisibleItemCount, 10, NULL); /* * Create an editable ComboBox with no entries. * Get the widget id of the drop down list, add some greek * letter names to it and select the third item in the list. */ n = 0; XtSetArg(args[n], DtNcomboBoxType, DtDROP_DOWN_COMBO_BOX); n++; XtSetArg(args[n], DtNorientation, DtLEFT); n++; XtSetArg(args[n], DtNcolumns, 10); n++; comboBox = DtCreateComboBox(parent, "comboBox2", args, n); XtManageChild(comboBox); list = XtNameToWidget(comboBox, "*List"); XmListAddItems(list, valueXmstrings, 7, 0); XtVaSetValues(list, XmNvisibleItemCount, 7, NULL); XtVaSetValues(comboBox, DtNselectedPosition, 3, NULL); /* * Create a non-editable ComboBox containing some greek letter names. * Position the arrow on the left. * Select the 'gamma' item in the list. */ n = 0; XtSetArg(args[n], DtNorientation, DtLEFT); n++; XtSetArg(args[n], DtNitems, valueXmstrings); n++; XtSetArg(args[n], DtNitemCount, numValueStrings); n++; XtSetArg(args[n], DtNvisibleItemCount, 8); n++; comboBox = DtCreateComboBox(parent, "comboBox3", args, n); XtManageChild(comboBox); xmString = XmStringCreateLocalized("gamma"); XtVaSetValues(comboBox, DtNselectedItem, xmString, NULL); XmStringFree(xmString); /* * Create a non-editable ComboBox with no entries. * Position the arrow on the right. * Add the greek letter names to the list and select the fourth item. */ n = 0; XtSetArg(args[n], DtNorientation, DtRIGHT); n++; XtSetArg(args[n], DtNvisibleItemCount, 8); n++; comboBox = DtCreateComboBox(parent, "comboBox4", args, n); XtManageChild(comboBox); for (i = 0; i < numValueStrings; i++) { DtComboBoxAddItem(comboBox, valueXmstrings[i], 0, True); } XtVaSetValues(comboBox, DtNselectedPosition, 4, NULL); /* * Free value and color strings, ComboBox has taken a copy. */ for (i = 0; i < numValueStrings; i++) { XmStringFree(valueXmstrings[i]); } XtFree((char*)valueXmstrings); for (i = 0; i < numColorStrings; i++) { XmStringFree(colorXmstrings[i]); } XtFree((char*)colorXmstrings); }
Widget CDeleteVariableAction::GetAttributesArea(Widget parent, symbolPtr* pSym){ XmString labelStr; Widget area = XtVaCreateWidget("area", xmFormWidgetClass, parent, XmNwidth, 450, XmNheight, 30, XmNnumColumns, 2, XmNpacking, XmPACK_COLUMN, XmNorientation, XmVERTICAL, NULL); string result; string command; string id = prepareQuery(CEntityInfo::etag(pSym)); setWait(true); CEntityInfo::exec("printformat \"%s\t%s\" name etag;", result); command = string("GetFunctionsUsingLocal " + id); CEntityInfo::exec("source_dis impacts.dis", result); CEntityInfo::exec(command,result); m_pClasses = new CQueryResult(); string cleanResult; cleanResult = m_pClasses->cleanUpResult(result, "(funct)"); if (cleanResult.size() >= 1) { m_pClasses->parse(cleanResult); if(m_pClasses->getRecordsCount()>0 ) { labelStr = XmStringCreateLocalized("Functions:"); Widget labelWidget = XtVaCreateManagedWidget("label_1",xmLabelGadgetClass, area, XmNlabelString, labelStr, XmNwidth, 100, XmNtopAttachment,XmATTACH_FORM, XmNleftAttachment,XmATTACH_FORM, XmNbottomAttachment,XmATTACH_FORM, NULL); XmStringFree(labelStr); m_ClassesList = XtVaCreateManagedWidget("Functions", dtComboBoxWidgetClass, area, XmNtopAttachment,XmATTACH_FORM, XmNleftAttachment,XmATTACH_WIDGET, XmNleftWidget, labelWidget, XmNrightAttachment,XmATTACH_FORM, XmNbottomAttachment,XmATTACH_FORM, NULL); TRecordSetIterator iter = m_pClasses->getStartRecord(); TRecordSetIterator end = m_pClasses->getEndRecord(); while(iter!=end) { TRecord* pRecord = *iter; labelStr = XmStringCreateLocalized((char*)(*pRecord)[1]->c_str()); DtComboBoxAddItem(m_ClassesList, labelStr, 0, false); XmStringFree(labelStr); iter++; } //while setWait(false); return area; } setWait(false); } else { XmString labelStr; labelStr = XmStringCreateLocalized("Deleting this variable requires changing the the functions arguments.\nPlease run Change Arguments instead."); Widget labelWidget = XtVaCreateManagedWidget("label_1", xmLabelGadgetClass, area, XmNlabelString, labelStr, XmNwidth, 150, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XmStringFree(labelStr); } setWait(false); return area; }