[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2719.0. "Adding translations to list widget" by CURIE::SENGUPTA (Shekhar Sengupta, ESG Marketing) Sun May 06 1990 14:41
I am trying unsuccessfully to override/augment translations in a list box
widget, such that pressing Button 3 will cause a call to an Action procedure
that will (eventually) create a pop up.
Is there anything obvious I am doing wrong?
Any help will be greatly appreciated.
Thanks
Shekhar
=============================================================================
#include <stdio.h>
#ifdef VMS
#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#include <decw$include/DwtAppl.h>
#include <sys$library/cda$def.h>
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/DwtAppl.h>
#endif
#define main_width 400
#define workwin_width (main_width - 24)
#define main_height 500
#define workwin_height (main_height - 24)
Widget top;
int screen;
Display *display;
static XtActionProc LsPopup(widget, event, params, nparams)
Widget widget;
XEvent *event;
char **params;
int *nparams;
{
Arg args[25];
int num_args;
printf ("entered list handler\n");
if ((event->type == ButtonRelease) && ((event->xbutton).button == Button3))
{
printf ("Popup comes here\n");
}
}
void listhandler(widget, tag, callback_data)
Widget widget;
caddr_t tag;
DwtListBoxCallbackStruct *callback_data;
{
printf("Event type = %d\n", (callback_data->event)->type);
if ((callback_data->event)->type == ButtonPress)
printf ("Button Press from list\n");
if ((callback_data->event)->type == ButtonRelease)
printf ("Button Release from list\n");
switch (callback_data->reason)
{
case DwtCRSingle : printf ("Item no. %d selected\n",
callback_data->item_number);
break;
case DwtCRExtend : printf("Item no. %d was last item selected\n",
callback_data->item_number);
}
}
static DwtCallback lcallback[] =
{
{listhandler, NULL},
{NULL, NULL}
};
static XtActionsRec my_actions[]= {"LsPopup", (XtActionProc)LsPopup};
static char *my_translations = "<Btn3Up>: LsPopup()";
main (argc, argv)
int argc;
char *argv[];
{
unsigned int width, height, border_width=9, x=0, y=0;
XtTranslations translations;
Arg args[25], a[25];
Widget main, list, workwin, parent_id;
XtAppContext app_context;
int num_args;
DwtCompString items[10];
items[0] = DwtLatin1String("This is a long string");
items[1] = DwtLatin1String("Item 2");
items[2] = DwtLatin1String("Item 3");
items[3] = DwtLatin1String("Item 4");
items[4] = DwtLatin1String("Very Very Very Long String");
items[5] = DwtLatin1String("Item 6");
items[6] = DwtLatin1String("Item 7");
items[7] = DwtLatin1String("Item 8");
items[8] = DwtLatin1String("Item 9");
items[9] = DwtLatin1String("Another long string");
XtToolkitInitialize();
app_context = XtCreateApplicationContext();
display = XtOpenDisplay(app_context, "", "wdemo", "WDEMO",
(XrmOptionDescRec *) NULL, 0, &argc, argv);
num_args = 0;
XtSetArg(args[num_args], DwtNx, 100); num_args++;
XtSetArg(args[num_args], DwtNy, 100); num_args++;
top = XtAppCreateShell("wdemo", "WDEMO", applicationShellWidgetClass,
display, args, num_args);
num_args = 0;
XtSetArg(a[num_args], DwtNwidth, main_width); num_args++;
XtSetArg(a[num_args], DwtNheight, main_height); num_args++;
XtSetArg(a[num_args], DwtNbackground, 1); num_args++;
XtSetArg(a[num_args], DwtNacceptFocus, TRUE); num_args++;
main = DwtMainWindowCreate(top, "mywin", a, num_args);
workwin = DwtWindow(main, "", 0, 0, workwin_width, workwin_height, NULL);
num_args = 0;
XtSetArg(args[num_args], DwtNx, 100); num_args++;
XtSetArg(args[num_args], DwtNy, 50); num_args++;
XtSetArg(args[num_args], DwtNwidth, 100); num_args++;
XtSetArg(args[num_args], DwtNitems, items); num_args++;
XtSetArg(args[num_args], DwtNitemsCount, 10); num_args++;
XtSetArg(args[num_args], DwtNresize, False); num_args++;
XtSetArg(args[num_args], DwtNhorizontal, True); num_args++;
XtSetArg(args[num_args], DwtNvisibleItemsCount, 5); num_args++;
XtSetArg(args[num_args], DwtNsingleSelection, False); num_args++;
XtSetArg(args[num_args], DwtNsingleCallback, lcallback); num_args++;
XtSetArg(args[num_args], DwtNextendCallback, lcallback); num_args++;
list = DwtListBoxCreate(workwin, "", args, num_args);
DwtMainSetAreas(main, NULL, workwin, NULL, NULL, NULL);
XtManageChild(main);
XtManageChild(workwin);
XtManageChild(list);
/* Install additional actions */
XtAppAddActions(app_context, my_actions, 1);
/* Compile translation */
translations = XtParseTranslationTable(my_translations);
/* Add or augment default translations - neither seems to work */
XtOverrideTranslations(list, translations);
XtRealizeWidget(top);
XtAppMainLoop (app_context);
}
T.R | Title | User | Personal Name | Date | Lines |
---|
2719.1 | Maybe this will help.. | TOWNS::RUFFIEUX | | Mon May 07 1990 20:54 | 15 |
| Shekhar,
Sorry, buy I don't have an answer... I looked at your example and
even ran it. I tried changing some things but could not get it to
work. It did work by making the 'list' widget a child of the 'main'
widget (instead of the 'workwin' widget). This leads to sizing
problems with the 'list' widget. As you can see, List Box widgets
are known to do funny things. Another suggestion is to try using
the DwtNtranslations attribute of the List Box widget. Have it
set to your translations table. (See 2-26 VOL 1A User Interface
Language). I've never used it but it looks like it might work.
CeR
|
2719.2 | Another possibility | DECWIN::KLEIN | | Tue May 08 1990 12:00 | 7 |
| Shekhar,
You might also want to try out the VList widget, which already has built-in
the functionality I think you are looking for. If you are interested,
send me mail for a pointer to the sources.
-steve-
|
2719.3 | Thank you | CURIE::SENGUPTA | Shekhar Sengupta, ESG Marketing | Fri May 11 1990 17:02 | 13 |
| re .2
Thank you for the offer Steve. I have been reading the material that
you have published on the Vlist widget and have a copy of the sources
from enthusiastic users in Systems Engg. in MRO. At this time it seems
that I may be able to do without having to do the popups. That in my
opinion would be the best solution since giving the sources of VLIST to
a customer has support implications that I am not comfortable with.
However, I do intend to use the VLIST widget if that is the only way.
At that time I will let you know.
Regards
Shekhar
|