[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 | 
2310.0. "Disappearing text widget cursors in scroll window" by TOOK::V_GILBERT () Tue Feb 20 1990 09:56
    I have a scroll window with many editable SText widgets.  Not all of
    the SText widgets are visible at any one time.  When the window is
    scrolled, the newly visible text widgets do not have visible
    cursors.  Is there any way that I can make the cursors be visible
    at any time that the text widget is visible?
    
    I have enclosed code that reproduces the problems.
    
    Any suggestions will be greatly appreciated.
    
    Thanks in advance,
    Verna
    
    
#include <stdio>
#include <decw$include/DECwDwtWidgetProg.h>
Widget 		toplevel;
Display 	*display;
Widget 		shell;
Widget 		mainw;
Widget 		scrollw;
Widget 		vsbar;
Widget 		dialog;
Widget 		menubar;
Widget 		menu;
Widget 		pulldownentry;
Widget 		pushbutton;
Widget 		label;
Widget 		text;
  
Dimension 	dbox_height = 240;
Dimension	dbox_width  = 300;
Dimension	scrollw_height = 100;
Dimension 	scrollw_width  = 300;
int		unit_inc=10;
int		page_inc=70;
int		maxvalue=100;
void exit_rtn();
void scrollbar_cb_rtn ();
static DwtCallback exit_cb[2]      = {{exit_rtn, NULL}, NULL};
static DwtCallback scrollbar_cb[2] = {{scrollbar_cb_rtn, NULL}, NULL};
main ()
{
   Arg          args[15];
   Arg          arglist[10];
                /* initialize stuff & create root widget - DONT REALIZE IT */
        toplevel = XtInitialize("toplevel_title", "scroll_window__class",NULL,0,&NULL,NULL);
        
        display = XtDisplay (toplevel);
        
        shell = XtAppCreateShell ("title", "shell_class", topLevelShellWidgetClass, display, NULL, 0);
	mainw = DwtMainWindow( shell, "MainWindow", 0, 0, 0, 0);
                /* create menubar as child of mainwindow */
        menubar = DwtMenuBar (mainw, "", NULL, NULL);
        XtSetArg (args[0], DwtNspacing, 20);
        XtSetValues (menubar, args, 1);
        XtManageChild (menubar);
                /* create pulldown menu for CONTROLS */
        menu = DwtMenu (menubar, "", NULL, NULL, DwtMenuPulldown, DwtOrientationVertical, NULL, NULL, NULL);
        pulldownentry = DwtPullDownMenuEntry (menubar, "", NULL, NULL, DwtLatin1String("Controls"), menu, NULL, NULL);
        XtManageChild (pulldownentry);
                /* create pushbutton entry for pulldown menu CONTROLS */
        pushbutton = DwtPushButton (menu, "", NULL, NULL, DwtLatin1String("Exit"), exit_cb, NULL);
        XtSetArg (args[0], DwtNalignment, DwtAlignmentBeginning);
        XtSetValues (pushbutton, args, 1);
        XtManageChild (pushbutton);
                /* create scroll window as child of main window  */
	scrollw = DwtScrollWindow(mainw,"ScrollWindow",0, 0, scrollw_width, scrollw_height);
        vsbar = DwtScrollBar (scrollw, "", 0, 0, NULL, NULL, unit_inc, page_inc, NULL, 0,
                               0, maxvalue, DwtOrientationVertical, NULL, 
                               NULL, scrollbar_cb,scrollbar_cb,scrollbar_cb,scrollbar_cb,
                               scrollbar_cb,scrollbar_cb,scrollbar_cb,scrollbar_cb);
                /*  create dialog box as work area for scroll window within dialog */
        XtSetArg (args[0], DwtNwidth, dbox_width);
        XtSetArg (args[1], DwtNheight, dbox_height);
        XtSetArg (args[2], DwtNunits, DwtPixelUnits);
        dialog = DwtDialogBoxCreate (scrollw, "dialog", args, 3);
                /* set scroll window areas */
        DwtScrollWindowSetAreas(scrollw,NULL,vsbar,dialog);
                /* set main window areas */
        DwtMainSetAreas(mainw,menubar,scrollw,NULL,NULL,NULL);
	XtSetArg(args[0], DwtNx, 10);
	XtSetArg(args[1], DwtNy, 0);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 1"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
	XtSetArg(args[1], DwtNy, 30);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 2"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
	XtSetArg(args[1], DwtNy,60);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 3"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
	XtSetArg(args[1], DwtNy,90);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 4"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
	XtSetArg(args[1], DwtNy,120);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 5"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
	XtSetArg(args[1], DwtNy, 150);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 6"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
	XtSetArg(args[1], DwtNy, 180);
	XtSetArg(args[2], DwtNlabel, DwtLatin1String("label 7"));
	label = DwtLabelGadgetCreate (dialog, "", args, 3);
	XtManageChild (label);
        text = DwtSText (dialog, "", 70, 0,  15 ,1, "");
        XtManageChild (text);
        text = DwtSText (dialog, "", 70, 30, 15 ,1, "");
        XtManageChild (text);                                                                              
        text = DwtSText (dialog, "", 70, 60, 15 ,1, "");
        XtManageChild (text);
        text = DwtSText (dialog, "", 70, 90, 15 ,1, "");
        XtManageChild (text);
        text = DwtSText (dialog, "", 70, 120, 15 ,1, "");                                           
        XtManageChild (text);
        text = DwtSText (dialog, "", 70, 150, 15 ,1, "");
        XtManageChild (text);
        text = DwtSText (dialog, "", 70, 180, 15 ,1, "");
        XtManageChild (text);
        XtManageChild(vsbar);
        XtManageChild(dialog);
        XtManageChild(scrollw);
        XtManageChild(mainw);
        XtRealizeWidget(shell);
        XtMainLoop();           /* Loop to handle events */
}
        /* exit application */
void exit_rtn (widget, tag, reason)
        Widget  widget;
        char    *tag;
        int     reason;
{
   XtDestroyWidget (shell);
   exit(1);
}
void scrollbar_cb_rtn (scrollbar, tag, p_callbackdata)
	Widget		scrollbar;
	int		*tag;
	DwtScrollBarCallbackStruct	*p_callbackdata;	                                                                                    
{
	Widget  	workarea;
	int		minval=0;
	int 		maxval=0;
	int		shown=0;
	int		unit_inc=0;
	int		val=0;
	int		page_inc=0;
	int		value_range;
	int 		new_val=0;
	unsigned char	orientation = (char)0;
	Dimension 	scrbar_wid=0;
	Dimension	scrbar_hei=0;
	Dimension	workarea_wid=0;
	Dimension	workarea_hei=0;
	Position	workarea_x=0;
	Position	workarea_y=0;
	Arg		scrbar_args[] = {{DwtNminValue, 	&minval},
					 {DwtNmaxValue, 	&maxval},
					 {DwtNwidth,    	&scrbar_wid},
		        		 {DwtNheight,   	&scrbar_hei},
					 {DwtNvalue,	  	&val},
			    		 {DwtNorientation, 	&orientation},
					 {DwtNinc, 	        &unit_inc},
					 {DwtNpageInc, 		&page_inc},
				         {DwtNshown,		&shown}};
	Arg		workarea_args[] = {{DwtNwidth,    	&workarea_wid},
			        	   {DwtNheight,   	&workarea_hei},
					   {DwtNx,	  	&workarea_x},
					   {DwtNy,	  	&workarea_y}};
   workarea = dialog;
   XtGetValues (scrollbar, scrbar_args, 9);
   XtGetValues (workarea, workarea_args, 4);
   value_range = maxval - minval - shown;
   switch (p_callbackdata->reason)
   {
      case DwtCRUnitInc:
      case DwtCRUnitDec:
      case DwtCRPageInc:
      case DwtCRPageDec:
      case DwtCRDrag:
         if (orientation == DwtOrientationHorizontal)
         {
            if (value_range <= 0)
               workarea_x = 0;
            else
               workarea_x = -abs(((p_callbackdata->value - minval) *
                                  (int)(workarea_wid - scrbar_wid)) /
                                   value_range);
            XtSetArg (workarea_args[0], DwtNx, workarea_x);
         }
         else
         {
            if (value_range <= 0)
               workarea_y = 0;
            else
               workarea_y = -abs(((p_callbackdata->value - minval) *
                                  (int)(workarea_hei - scrbar_hei)) /
                                  value_range);
            XtSetArg (workarea_args[0], DwtNy, workarea_y);
         }
         XtSetValues (workarea, workarea_args, 1);
         break;
      case DwtCRToTop:
         if (orientation == DwtOrientationHorizontal)
         {
            workarea_x = workarea_x - p_callbackdata->pixel;
            if (workarea_x < (scrbar_wid - workarea_wid))
               workarea_x = scrbar_wid - workarea_wid;
            XtSetArg (workarea_args[0], DwtNx, workarea_x);
            if (scrbar_wid >= workarea_wid)
               new_val = minval;
            else
               new_val = (((int)workarea_x * value_range) /
                           (int)(scrbar_wid - workarea_wid)) + minval;
         }
         else
         {
            workarea_y = workarea_y - p_callbackdata->pixel;
            if (workarea_y < (scrbar_hei - workarea_hei))
               workarea_y = scrbar_hei - workarea_hei;
            XtSetArg (workarea_args[0], DwtNy, workarea_y);
            if (scrbar_hei >= workarea_hei)
               new_val = minval;
            else
               new_val = (((int)workarea_y * value_range) /
                           (int)(scrbar_hei - workarea_hei)) + minval;
         }
         XtSetValues (workarea, workarea_args, 1);
         if (val != new_val)
            DwtScrollBarSetSlider (scrollbar, new_val, shown, unit_inc, page_inc, FALSE);
         break;
      case DwtCRToBottom:
         if (orientation == DwtOrientationHorizontal)
         {
            workarea_x = workarea_x + (scrbar_wid - p_callbackdata->pixel - 1);
            if (workarea_x > 0)
               workarea_x = 0;
            XtSetArg (workarea_args[0], DwtNx, workarea_x);
            if (scrbar_wid >= workarea_wid)
               new_val = minval;
            else
               new_val = (((int)workarea_x * value_range) /
                           (int)(scrbar_wid - workarea_wid)) + minval;
         }
         else
         {
            workarea_y = workarea_y + (scrbar_hei - p_callbackdata->pixel - 1);
            if (workarea_y > 0)
               workarea_y = 0;
            XtSetArg (workarea_args[0], DwtNy, workarea_y);
            if (scrbar_hei >= workarea_hei)
               new_val = minval;
            else
               new_val = (((int)workarea_y * value_range) /
                           (int)(scrbar_hei - workarea_hei)) + minval;
         }
         XtSetValues (workarea, workarea_args, 1);
         if (val != new_val)
            DwtScrollBarSetSlider (scrollbar, new_val, shown, unit_inc, page_inc, FALSE);
         break;
   }      
}            
| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 2310.1 | Reply posted in HARBOR::DECWINDOWS_PROGRAMMING, 683.1 | RTL::JUNE |  | Thu Feb 22 1990 14:54 | 0 |