[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 |
1118.0. "Auto Sizing of widget problem??" by LARVAE::BULLARD () Mon Jul 17 1989 13:41
/* The following program creates a main window widget with a width and
height of zero.According to the documentation the size of this widget
should then size itself according to the work window widget.In this
case this is a menu create widget.The height of the main window widget
is incorrect and can be corrected by fetching the height of the work
window widget and explicitly setting the height of the main window
widget.
Can anyone see an error or a usage problem?
regards Mark
p.s. The following works but is distilled from a larger program and
so might have some redundant stuff in it,sorry!!
The code follows and this is the build command:-
$cc 'p1'
$link/exe='p1' sys$input:/opt
sizing.obj,-
sys$share:decw$xlibshr.exe/share
sys$share:vaxcrtl.exe/share
sys$share:decw$dwtlibshr.exe/share */
#include <decw$include/DwtAppl.h>
#include <decw$include/vendor.h>
Display *dp = 0;
unsigned long acontext = 0;
static exp_call ();
static DwtCallback exp_callp[] = {exp_call, 0, NULL};
static menu_call ();
static DwtCallback menu_callp [] = {menu_call,0,NULL};
int main (ac,av)
int ac;
char **av;
{
int i,j;
Widget sw,nw,mw,hs,vs,box,mb,mu;
char *class = "TESTCLASS";
Arg tav [10];
int tac = 0;
unsigned short wd,ht;
--ac, ++av;
XtToolkitInitialize ();
acontext = XtCreateApplicationContext();
dp = XtOpenDisplay (acontext,"0::0:0","myapp1",class,NULL,0,&ac,&av);
printf ("acontext =%x,display=%x\n",acontext,dp);
XSynchronize (dp,1);
XtSetArg (tav[0],DwtNx,100);
XtSetArg (tav[1],DwtNy,100);
XtSetArg (tav[2],XtNallowShellResize,TRUE);
XtSetArg (tav[3],XtNinput,TRUE);
tac = 4;
sw = XtAppCreateShell ("Menu",class,topLevelShellWidgetClass,dp,tav,
tac);
printf ("Shell widget no = %x\n",sw);
tac=0;
XtSetArg (tav[0],DwtNwidth,0);
XtSetArg (tav[1],DwtNheight,0);
tac=2;
nw = DwtMainWindowCreate (sw,"myapp3",tav,tac);
printf ("Main window widget no = %x\n",mw);
for (j = 1 ; j < 2; ++j)
{
char tbuf [40];
XtSetArg (tav[0],DwtNorientation,DwtOrientationVertical);
XtSetArg (tav[1],DwtNentryCallback ,&menu_callp);
mu = DwtWorkBoxCreate(nw,"Mymenu1",tav,2);
tac = 1;
for (i = 1; i <= 5 * j; ++i)
{
Widget mi;
char buf [40];
XtSetArg(tav[0],DwtNuserData, i+j*256);
sprintf (buf," Option %d \n",i);
mi=DwtPushButtonCreate (mu,buf,tav,tac);
XtManageChild (mi);
printf ("menu entry %d widget%x\n",i,mi);
}
XtSetArg(tav[0],DwtNworkWindow,mu);
XtSetValues (nw,tav,1);
XtManageChild (mu);
}
XtManageChild (nw);
XtRealizeWidget (sw);
/* Work round to get over the size problem */
waitit (sw);
XtSetArg (tav[0], DwtNheight, &ht);
XtGetValues (mu,tav,1);
XtSetArg (tav[0],DwtNheight,ht);
XtSetValues (nw,tav,1);
printf ("realized main widget - entering main loop\n");
waitit (sw);
XtAppMainLoop (acontext);
printf ("Main loop exit\n");
waitit (sw);
return (1);
}
waitit (wd)
Widget wd;
{
char buf [100];
printf ("Enter C/r to continue?...\n");
getchar(0);
return;
}
static exp_call (wj,tag,p)
Widget wj;
int tag;
DwtWindowCallbackStruct *p;
{
XExposeEvent *e;
printf ("exp call called - widget= %x,tag=%d reason =%d,window=%x\n",
wj,tag,p->reason,p->w);
if (p->reason == DwtCRExpose)
{
e = p->event;
printf("Expose window =%x x=%d,y= %d,width = %d,height=%d\n",
e->window,e->x,e->y,e->width,e->height);
}
}
static menu_call (wj,tag,p)
Widget wj;
int tag;
DwtMenuCallbackStruct *p;
{
XEvent *e;
static int done[2] = 0;
int j;
printf("menu_call_called-widget= %x,tag=%d reason =%d,sub-widget=%x\n",
wj,tag,p->reason,p->s_widget);
if (p->reason == DwtCRActivate)
{
Arg tv [4];
int ud;
XtSetArg (tv[0],DwtNuserData,&ud);
XtGetValues (p->s_widget,tv,1);
printf ("menu entry no %d in menu %d selected\n",ud %256,
ud/256);
}
}
T.R | Title | User | Personal Name | Date | Lines |
---|
1118.1 | | LEOVAX::TREGGIARI | | Tue Jul 18 1989 12:56 | 9 |
| > mu = DwtWorkBoxCreate(nw,"Mymenu1",tav,2);
I think the problem is that you think this is creating some kind of menu
widget. This creates a work-in-progress box which is a *popup* widget.
The main window must have a normal child, not a popup child, for the
work area. I think you want to use DwtMenuCreate.
Leo
|
1118.2 | Still doesn't work... | LARVAE::BULLARD | | Thu Jul 20 1989 07:04 | 7 |
| I've tried using DwtMenuCreate but with the same result.Is this
a usage problem? If so I can't see what I am doing wrong.
Any ideas ?
regards Mark
|