Пример #1
0
/* do_window()
 * ================================================================
 */
void
do_window( int *msg, int *event )
{
    switch( msg[0] )
    {
      case WM_REDRAW:   do_redraw( msg );
			break;
	

      case WM_TOPPED:	/* make this the top window */
			if( msg[3] == wid )
			    wind_set( msg[3], WF_TOP );
			break;	

      case WM_CLOSED:   CheckExit();
			break;	

      case WM_ARROWED:
			break;	

      case WM_HSLID:
			break;	
      case WM_VSLID:
			break;	

      case WM_MOVED:    do_move( msg );
			break;	

      default:
		break;
    }
}
Пример #2
0
/**
 * gtk_source_gutter_queue_draw:
 * @gutter: a #GtkSourceGutter.
 *
 * Invalidates the drawable area of the gutter. You can use this to force a
 * redraw of the gutter if something has changed and needs to be redrawn.
 *
 * Since: 2.8
 */
void
gtk_source_gutter_queue_draw (GtkSourceGutter *gutter)
{
	g_return_if_fail (GTK_SOURCE_IS_GUTTER (gutter));

	do_redraw (gutter);
}
Пример #3
0
void
Dclick_Redraw( void )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ GENERAL ];
   int old_dclick = cur_value.dclick;
   
   Get_Dclick();
   Dclick_Update();

   if( old_dclick != cur_value.dclick )
   {
      Deselect( old_dclick + M0 );
      do_redraw( tree, old_dclick + M0 ); 
      do_redraw( tree, cur_value.dclick + M0 );
   }
}
Пример #4
0
void
Block2_Redraw( void )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ GENERAL ];
   
   int Old_STE = cur_value.STE_Chip;
   int Old_Speaker = cur_value.TT_Speaker;
   
   Get_Block2();
   Block2_Update();

   if( IsSTE() && ( Old_STE != cur_value.STE_Chip ) )
   	do_redraw( tree, BLK2BUTT );
   
   if( IsSpeaker() && ( Old_Speaker != cur_value.TT_Speaker ) )
        do_redraw( tree, BLK2BUTT );
}
Пример #5
0
void
Kbell_Redraw( void )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ GENERAL ];
   int old_key  = cur_value.keyclick;
   int old_bell = cur_value.bell;
   
   Get_Keybell();
   Keybell_Update();
   
   if( old_key != cur_value.keyclick )
	do_redraw( tree, KEYICON );
	   
   if( old_bell != cur_value.bell )
        do_redraw( tree, BELLICON );
   	
}
Пример #6
0
/*
 * Get a single event, process it, and return.
 *
 */
domulti(){
    int event;
  
    event = evnt_multi(MU_MESAG,
			1,1,butdown,
			0,0,0,0,0,
			0,0,0,0,0,
			msgbuff,0,0,&mx,&my,&ret,&ret,&keycode,&ret);
  
    if (event & MU_MESAG)
        switch (msgbuff[0]) {
	    case WM_REDRAW:
		do_redraw(msgbuff[4],msgbuff[5],msgbuff[6],msgbuff[7]);
		break;
	
	    case WM_NEWTOP:
	    case WM_TOPPED:
		wind_set(wi_handle, WF_TOP, 0, 0, 0, 0);
		break;
	
	    case WM_CLOSED:
		running = FALSE;
		break;
	
	    case MN_SELECTED:
		graf_mouse(HOURGLASS, 0L);
		switch(msgbuff[3]) {
		    case MNDESK:
			if(msgbuff[4] == DEABOUT) {
			    strcpy((about[ABVERSN].ob_spec)->te_ptext, "6.00");
			    about[ABOK].ob_state = NORMAL;
			    execform(about);
			    }
			break;		/* "cannot happen" */

		    case MNFILE:
			switch (msgbuff[4]) {
			    case FIQUIT:	/* [QUIT] item */
				running = 0;
				break;

			    case FIINST:	/* [INSTALL] item */
				install();
				break;
		
			    case FIUNINST:	/* [UNINSTALL] item */
				uninstall();
				break;
			}
			break;
		}
		menu_tnormal(menubar, msgbuff[3], 1); /* back to normal */
        	graf_mouse(ARROW, 0L);	/* restore mouse */
		break;
	}
}
Пример #7
0
static void SDL_update(void)
{
  int i;
  pthread_mutex_lock(&rects_mtx);
  i = sdl_rects_num;
  sdl_rects_num = 0;
  pthread_mutex_unlock(&rects_mtx);
  if (i > 0)
    do_redraw();
}
Пример #8
0
/* exported function documented in fbtk.h */
int
fbtk_redraw(fbtk_widget_t *widget)
{
    fbtk_widget_t *root;

    /* ensure we have the root widget */
    root = fbtk_get_root_widget(widget);

    return do_redraw(root->u.root.fb, root);
}
Пример #9
0
static int
do_redraw(nsfb_t *nsfb, fbtk_widget_t *widget)
{
    nsfb_bbox_t plot_ctx;
    fbtk_widget_t *cwidget; /* child widget */


    LOG(("DO REDRAW"));
    //__menuet__debug_out("\n***********\nDO REDRAW\n********\n");
    /* check if the widget requires redrawing */
    if (widget->redraw.needed == true) {
        plot_ctx.x0 = fbtk_get_absx(widget) + widget->redraw.x;
        plot_ctx.y0 = fbtk_get_absy(widget) + widget->redraw.y;
        plot_ctx.x1 = plot_ctx.x0 + widget->redraw.width;
        plot_ctx.y1 = plot_ctx.y0 + widget->redraw.height;

        LOG(("clipping %p %d,%d %d,%d",
             widget, plot_ctx.x0, plot_ctx.y0,
             plot_ctx.x1, plot_ctx.y1));
        if (nsfb_plot_set_clip(nsfb, &plot_ctx) == true) {

            LOG(("POST CALLBACK"));
            //__menuet__debug_out("\n***********\nPOST CALLBACK\n********\n");

            fbtk_post_callback(widget, FBTK_CBT_REDRAW);
        }
        widget->redraw.needed = false;
    }


    LOG(("DO CHILD"));
    //__menuet__debug_out("\n***********\nDO CHILD\n********\n");

    /* walk the widgets children if child flag is set */
    if (widget->redraw.child) {
        LOG(("DO CHILD 2"));
        //__menuet__debug_out("\n***********\nDO CHILD 2\n********\n");
        cwidget = widget->last_child;
        while (cwidget != NULL) {
            LOG(("DO CHILD 3 ZZZ"));
            //__menuet__debug_out("\n***********\nDO CHILD 3 ZZZ\n********\n");
            do_redraw(nsfb, cwidget);
            cwidget = cwidget->prev;
        }
        LOG(("DO CHILD 4"));
        //__menuet__debug_out("\n***********\nDO CHILD 4\n********\n");
        widget->redraw.child = false;
    }


    LOG(("SUP"));
    //__menuet__debug_out("\n***********\nFIN REDRAW\n********\n");

    return 1;
}
Пример #10
0
/* Wm_Redraw()
 *==========================================================================
 * Handle main event_multi window redraw messages.
 * 
 * IN:  int *msg:	Event messages
 * OUT: void
 *
 * GLOBAL:     WINFO  w:       window structure
 *	       int xconfig:    The index of which config routine is active
 *			       -1 when none active
 */
void
Wm_Redraw( int *msg )
{
   GRECT  *rect;

   if( msg[3] == w.id )
   {
      rect = (GRECT *)&msg[4];
      do_redraw( tree, rect );
   }      
}
Пример #11
0
void
Speed_Redraw( void )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ GENERAL ];
   int old_value = cur_value.BlitCache;
   
   Get_Speed();
   Speed_Update();

   if( old_value != cur_value.BlitCache )
   	do_redraw( tree, BLK1BUTT );
}
Пример #12
0
void
Redraw_Objects( void )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ PRINTER ];
   PRT oldnums;
   
   oldnums = cur_value;
   
   Get_Printer( &cur_value );
   set_objects();
   
   if( oldnums.cur_type != cur_value.cur_type )
   	do_redraw( tree, PTYPE );
   	
   if( oldnums.cur_color != cur_value.cur_color )
   	do_redraw( tree, COLOR );
   	
   if( oldnums.cur_pixel != cur_value.cur_pixel )
        do_redraw( tree, PIXLINE );
        
   if( oldnums.cur_quality != cur_value.cur_quality )
        do_redraw( tree, QUALITY );
        
   if( oldnums.cur_port != cur_value.cur_port )
   	do_redraw( tree, PORT );

   if( oldnums.cur_paper != cur_value.cur_paper )
   	do_redraw( tree, PAPER );
}
Пример #13
0
/* mover_keys()
 *==========================================================================
 * Handle the RENAME/MOVER XCONFIG KEYBOARD handling.
 * IN: void
 * OUT: BOOLEAN - 	TRUE - Exit the Mover Functions
 *			FALSE - Don't exit
 */
BOOLEAN
mover_keys( void )
{
   BOOLEAN flag = FALSE;
      
   if( xtree == ( OBJECT *)rs_trindex[ MOVECPX ] )
   {
      Delete_Fnodes();
      tree = xtree = ( OBJECT *)rs_trindex[ XINFO ];
      ObX( ROOT ) = w.phy.g_x;
      ObY( ROOT ) = w.phy.g_y;
      do_redraw( xtree, ROOT, &w.phy );
      flag = TRUE;
   }
   return( flag );
}
Пример #14
0
clr_dicons( )
{
	GRECT		pt;
	REG OBJECT	*obj;
	WORD		i;

	obj = background;

	if ( build_rect( obj, &pt, d_xywh[6], d_xywh[9] ) )
	{
	  for ( i = 1; i <= obj[0].ob_tail; i++ )
	    obj[i].ob_state = NORMAL;	

	  do_redraw( 0, &pt, 0 );
	}	

}
Пример #15
0
static gboolean
on_view_button_press_event (GtkSourceView    *view,
                            GdkEventButton   *event,
                            GtkSourceGutter  *gutter)
{
	Renderer *renderer;
	GtkTextIter line_iter;
	gint start = -1;
	GdkRectangle rect;

	if (event->window != gtk_source_gutter_get_window (gutter))
	{
		return FALSE;
	}

	if (event->type != GDK_BUTTON_PRESS)
	{
		return FALSE;
	}

	/* Check cell renderer */
	renderer = renderer_at_x (gutter, event->x, &start, NULL);

	if (renderer_query_activatable (gutter,
	                                renderer,
	                                (GdkEvent *)event,
	                                (gint)event->x,
	                                (gint)event->y,
	                                &line_iter,
	                                &rect,
	                                start))
	{
		gtk_source_gutter_renderer_activate (renderer->renderer,
		                                     &line_iter,
		                                     &rect,
		                                     (GdkEvent *)event);

		do_redraw (gutter);

		return TRUE;
	}

	return FALSE;
}
Пример #16
0
/* Wm_Redraw()
 *==========================================================================
 * Handle main event_multi window redraw messages.
 * 
 * IN:  int *msg:	Event messages
 * OUT: void
 *
 * GLOBAL:     WINFO  w:       window structure
 *	       int xconfig:    The index of which config routine is active
 *			       -1 when none active
 */
void
Wm_Redraw( int *msg )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ XCONTROL ];
   GRECT  *rect;
   int    mainbase;

   if( msg[3] == w.id )
   {
      rect = (GRECT *)&msg[4];
      if( !IsCPXActive() )
      {
	 mainbase = ( ( !IsXconfigActive() ) ? ( ROOT ) : ( TIMEBASE ) );
	 time_handle();
         do_redraw( tree, mainbase, rect );
         w.phy = ObRect( XBASE );
         objc_offset( tree, XBASE, &w.phy.g_x, &w.phy.g_y );
         redraw_xconfig( rect, &w.phy );
      }
      Redraw_XForm_Do( rect );
      cpx_draw( rect );
   }      
}
Пример #17
0
/* Redraw_Objects()
 *==========================================================================
 * Redraws the modem objects.
 * This is especially important if the values are changed, therefore
 * they must reflect actual reality
 */
void
Redraw_Objects( void )
{
   OBJECT *tree = ( OBJECT *)rs_trindex[ RS232 ];
   MDATA temp;
   int   xport;
   int   i;
   int   temp_port;
   
   store = ( BUFFER *)(*xcpb->Get_Buffer)();
   
   xport = temp_port = Get_Active_Port();
   Set_Number_Of_Ports();
   temp  = Modem.modem[ temp_port ];

   for( i =0;i < Num_Ports;i++ )
   {
       Read_Port( i, store );
       store++;   
   }
   Set_Active_Port( temp_port );
   set_objects( cur_port );
      
   if( xport != cur_port )
       do_redraw( tree, PORT );
          
   if( temp.cur_baud != Modem.modem[ cur_port ].cur_baud )
         do_redraw( tree, BAUD );
         
   if( temp.cur_parity != Modem.modem[ cur_port ].cur_parity )
   	do_redraw( tree, PARITY );
   	
   if( temp.cur_bits != Modem.modem[ cur_port ].cur_bits )
       do_redraw( tree, BITSCHAR );
       
   if( temp.cur_flow != Modem.modem[ cur_port ].cur_flow )
   	do_redraw( tree, FLOW );
   	
   if( temp.cur_stop != Modem.modem[ cur_port ].cur_stop )
   	do_redraw( tree, STOPX );
}
Пример #18
0
/* cpx_call()
 * ======================================================================
 * Called ONLY when the CPX is being executed. Note that it is CPX_INIT()
 * that returned the ptr to cpx_call().
 * CPX_CALL() is the entry point to displaying and manipulating the
 * dialog box.
 *
 * IN: GRECT *rect:	Ptr to a GRECT that describes the current work
 *			area of the XControl window.
 *
 * OUT:
 *   FALSE:     The CPX has exited and no more messages are
 *		needed.  XControl will either return to its
 *		main menu or close its windows.
 *		This is used by XForm_do() type CPXs.
 *
 *   TRUE:	The CPX requests that XCONTROL continue to
 *		send AES messages.  This is used by Call-type CPXs.
 */
BOOLEAN
cpx_call( GRECT *rect )
{
     int     button;
     int     quit = 0;
     WORD    msg[8], clip[4];
     MRETS   mk;
     int     ox, oy;
     BOOLEAN dclick;
     int     CurPen;
     GRECT   orect;

     ActiveTree( ad_tree );

     WindGet(0, WF_WORKXYWH, &desk );	/* set clipping to */
     rc_2xy( &desk, clip );			/*   Desktop space */

     open_vwork();
     vs_clip( vhandle, 1, ( int *)clip );
     ObX( ROOT ) = rect->g_x;
     ObY( ROOT ) = rect->g_y;
     ObjcDraw( tree, ROOT, MAX_DEPTH, NULL );
     draw_boxes();			/* draw the color boxes */
     outline( curbox, HILITE );		/* show selected box */
     close_vwork();

     
     do
     {
        dclick = FALSE;
	button = (*xcpb->Xform_do)( tree, 0, msg );

	if(( button != -1 ) && ( button & 0x8000 ) )
        {
	   dclick = TRUE;
	   button &= 0x7fff;
        }

     	switch( button )
     	{
	   case CCANCEL:
		         cnclchgs();			/* cancel all changes made */
     	
     	   case C*K: quit = TRUE;
     	   	     Deselect( button );
     	   	     break;

 	   case CRELOAD:		/* reload saved user-preference */
	   		if( saved )
	   		  init(&usr_vals);
	   		else
	   		  init(&def_vals);
		        update_rgb(1);	/* update RGB on screen */

			/* Redraw the boxes deliberately */
		        open_vwork();
		        rc_2xy( &desk, clip );		/*   Desktop space */
			vs_clip( vhandle, 1, ( int *)clip );
			draw_boxes();			/* draw the color boxes */
			close_vwork();

			
	   		XDeselect( tree, button );
			break;


	   case CSAVE:	/* save current values */
			if ((*xcpb->XGen_Alert)(SAVE_DEFAULTS) == TRUE)
			{
			    (*xcpb->MFsave)(MFSAVE, &orig_mf);
			    if( AES_Version >= 0x0320 )
			        graf_mouse( BUSYBEE, 0L );
					
			    savergb();			/* save color info */
							/* update RGBs */
			    cpyrgb((RGB *)&oldrgb, (RGB *)&newrgb, numcol );	

			    /* save current data to file */
			    saved = 1;
			    (*xcpb->CPX_Save)((void *)&saved, sizeof(DEFAULTS)+2);
 	    		    (*xcpb->MFsave)(MFRESTORE, &orig_mf);
			}
			XDeselect( tree, button );
	   		break;


	   case CUP:
	   		(*xcpb->Sl_arrow)(tree, CBASE, CSLIDE, CUP, -1, 
	    			col_max, col_min, &curcol, VERTICAL, nxtrow);
	    		break;
	    		
	   case CDOWN:
	    		(*xcpb->Sl_arrow)(tree, CBASE, CSLIDE, CDOWN, 1, 
	    			col_max, col_min, &curcol, VERTICAL, nxtrow);
	    		break;


   	   case CSLIDE:
			if( dclick )	/* if double-click */
			{
			    ActiveTree( ad_tree );
			    orect = ObRect( CSLIDE );
			    objc_offset( ad_tree, CSLIDE, &orect.g_x, &orect.g_y );
			    
			    ActiveTree( ad_slide1 );
			    ObX( CTSLIDE ) = ObX( EXIT1 ) = ( orect.g_x - 2 );
			    ObY( CTSLIDE ) = ObY( EXIT1 ) = ( orect.g_y - 2 );
			    ObW( CTSLIDE ) = ( orect.g_w + 3 );
			    ObH( CTSLIDE ) = ( orect.g_h + 4 );

			    myitoa( curcol, &PenNum[0] );
			    TedText( CTSLIDE ) = PenNum;

			    ObjcDraw( ad_slide1, CTSLIDE, 0, NULL );
			    form_do( ad_slide1, CTSLIDE );

			    if( strlen( TedText( CTSLIDE ) ) )
			    {
			    			    
			      CurPen = atoi( TedText( CTSLIDE ) );
			      CurPen = min( CurPen, col_max );
			      CurPen = max( CurPen, col_min );
			      curcol = CurPen;
			      Deselect( CTSLIDE );
			      Deselect( EXIT1 );
			
			      ActiveTree( ad_tree );
			      ObjcDraw( ad_tree, CSLIDE, MAX_DEPTH, NULL );
			    
		   	      headcol = ( curcol / COL_PER_BNK )* COL_PER_BNK;
			      open_vwork();
			      rc_2xy( &desk, clip );	
			      vs_clip( vhandle, 1, ( int *)clip );
			      draw_boxes();
     			      close_vwork();
			      nxtgrp();
			      update_slid( CBASE, CSLIDE, curcol, col_max, col_min, 1 );
			    }
			    else
                            {
			      Deselect( CTSLIDE );
			      Deselect( EXIT1 );
			      ActiveTree( ad_tree );
			      ObjcDraw( ad_tree, CSLIDE, MAX_DEPTH, NULL );
                            }
			    EvntButton( 1, 1, 0, &mk );
			}
			else
 			{
			  (*xcpb->MFsave)(MFSAVE, &orig_mf);
			  if( AES_Version >= 0x0320 )
			      graf_mouse( FLAT_HAND, 0L );

          		  if(( AES_Version >= 0x0330 )
	      		      && ( numcol > LWHITE ) )
			     XSelect( tree, CSLIDE );

	    		  (*xcpb->Sl_dragy)(tree, CBASE, CSLIDE, col_max, 
	    			col_min, &curcol, nxtgrp);

          		  if(( AES_Version >= 0x0330 )
	      		      && ( numcol > LWHITE ) )
			      XDeselect( tree, CSLIDE );
	    		  (*xcpb->MFsave)(MFRESTORE, &orig_mf);
			}
			break;

	   case CBASE:  
			Graf_mkstate(&mk);
		        objc_offset(tree, CSLIDE, &ox, &oy);
			if(mk.y < oy)
			    oy = -col_page;
			else
			    oy = col_page;
			curslid = CSLIDE;
			(*xcpb->Sl_arrow)(tree, CBASE, CSLIDE, -1, oy, 
   		     			 col_max, col_min, &curcol, VERTICAL, nxtpage);

	    		break;


	   case RUP:    Do_Up( RBASE, RSLIDE, RUP, R );
	    		break;
	    		
	   case RDOWN:  Do_Down( RBASE, RSLIDE, RDOWN, R );
	    		break;
	    		
	   case RSLIDE: Do_Slider( RBASE, RSLIDE, R, dclick );
	    		break;
	    		
	   case RBASE:  Do_Base( RBASE, RSLIDE, R );
	    		break;
	        
  	   case GUP:    Do_Up( GBASE, GSLIDE, GUP, G );
	    		break;
	    		
	   case GDOWN:  Do_Down( GBASE, GSLIDE, GDOWN, G );
	    		break;
	    		
	   case GSLIDE: Do_Slider( GBASE, GSLIDE, G, dclick );
			break;
	    		
	   case GBASE:  Do_Base( GBASE, GSLIDE, G );
	    		break;
	   
	        
	   case BUP:    Do_Up( BBASE, BSLIDE, BUP, B );
	    		break;
	    		
	   case BDOWN:  Do_Down( BBASE, BSLIDE, BDOWN, B );
	    		break;
	    		
	   case BSLIDE: Do_Slider( BBASE, BSLIDE, B, dclick );
			break;
	    		
	   case BBASE:  Do_Base( BBASE, BSLIDE, B );
	    		break;


  	   case TWO01:		/* for ST High rez */
	   case TWO02:
	
	   case FOUR01:		/* for ST Medium rez */
	   case FOUR02:
	   case FOUR03:
	   case FOUR04:
		
	   case BOX0:    	/* for all other rez */
	   case BOX1:
	   case BOX2:
	   case BOX3:
	   case BOX4:
	   case BOX5:
	   case BOX6:
	   case BOX7:
	   case BOX8:
	   case BOX9:
	   case BOX10:
	   case BOX11:
	   case BOX12:
	   case BOX13:
	   case BOX14:
	   case BOX15:
	  		if( button != curbox)	/* select requested color */
	  		{
			    curcol = button - headbox + headcol;
			    nxt_to_show(0);
			    update_slid( CBASE, CSLIDE, curcol, col_max, col_min, 1 );
			}
	   		break;

     	   default:	if( button == -1 )
     			{
     			   switch( msg[0] )
     			   {
     			     case WM_REDRAW: /* redraw the cpx */
		  			     do_redraw((GRECT *)&msg[4], (int *)clip);
     			     		     break;
     			     		     
     			     case AC_CLOSE:  /* treated like a cancel */
	 				     cnclchgs();	/* cancel changes made */
     			     case WM_CLOSED: quit = TRUE; 	/* treated like an OK */
					     break;
					     
			     case CT_KEY:
			     	switch( msg[3] )	/* check which key is returned */
			     	{
					case UNDO:			/* if Undo key */
						   cnclbnk();		/* cancel color changes */
						   update_rgb(1);	/* update RGB on screen */

						   /* Redraw the boxes deliberately */
		        			   open_vwork();
		        			   rc_2xy( &desk, clip );		/*   Desktop space */
						   vs_clip( vhandle, 1, ( int *)clip );
						   draw_boxes();			/* draw the color boxes */
						   close_vwork();

						   break;
						
					case HOME:				/* if Clr Home key */
						   init(&def_vals);	/* init to system defs */
						   update_rgb(1);	/* update RGB on screen */

						   setup_bnk = CLEAN;/*cjg*/	
						   visit_bnk();	     /*cjg*/

						   /* Redraw the boxes deliberately */
		        			   open_vwork();
		        			   rc_2xy( &desk, clip );		/*   Desktop space */
						   vs_clip( vhandle, 1, ( int *)clip );
						   draw_boxes();			/* draw the color boxes */
						   close_vwork();

						   break;
				}

			     		     break;		     
     			     default:
     			     		break;
     			   }
     			}
     			break;
     	}
     }while( !quit);
     return( FALSE );
}
Пример #19
0
/* ................................................................
 * Handle user interaction with a form in open window `w'.
 *
 * Initial conditions are as follows:
 * w->x is the address of the form.
 * window is open, with appropriate WINFO rects & coordinates set
 * form is drawn within window, at correct virtual coordinates
 * ROOT object of form has correct x,y coordinates
 *
 * This routine works just like form_do, but dispatches window
 * events, redrawing and fixing up the object tree as appropriate,
 * and maintaining the various rects and coordinates in the WINFO struct.
 *
 * Returns exit object selected, |= 0x8000 if double clicked a TOUCHEXIT,
 * OR -1 if a message was received which couldn't be handled.
 * In the latter case, the `puntmsg' array is filled with the message buffer
 * which xform_do() couldn't handle, and the application is responsible for
 * picking up where xform_do() left off.  A cop-out, I know.
 *
 * NOTE: form_dial( FMD_START,... ) and form_dial( FMD_FINISH,... )
 *		should NOT be used with xform_do().
 *
 * User defined objects could cause problems with this routine, as
 * the boundary of the object may lie outside the window coordinates.
 * Caveat programmer.
 */
WORD
xform_do( OBJECT *tree, WORD start_field, WORD puntmsg[] )
{
	WORD	next_obj, edit_obj, idx;
	BOOLEAN	cont, doedit;
	WORD	event;
	MRETS	m;
	WORD	key, clicks;
	DIRS	direction; /* form_keybd */
	GRECT	rect;

        SetWmCloseState( FALSE );
        SetAccCloseState( FALSE );
        
	/*
	 * Get the next editable object
	 */
	if( start_field == 0 )
		next_obj = find_obj( tree, 0, FORWARD );
	else
		next_obj = start_field;

	edit_obj = 0;
	cont = TRUE;
	
	cursor = FALSE;
	
	while( cont ) {

		/*
		 * Put the cursor in the edit field
		 * Note: This is skipped if there is only one field.
		 */
		if( (next_obj != 0) && (edit_obj != next_obj) ) {
			edit_obj = next_obj;
			next_obj = 0;
			doedit = can_edit( tree, edit_obj );
			if( doedit && !cursor )
			{
				objc_edit( tree, edit_obj, 0, (int *)&idx, ED_INIT );
				cursor = TRUE;
			}	
		}

		if( !_app )			/* cjg 06/18/93 ---ACC */
		     wind_update( END_UPDATE );

		/*
		 * Wait...
		 */
		event = Evnt_multi( MU_KEYBD|MU_BUTTON|MU_MESAG, 2, 1, 1,
							NULL, NULL, msg, 0L, &m, &key, &clicks );

		wind_update( BEG_UPDATE );		/* cjg 06/18/93  - PRG */

		if( EvMessage() ) {
			switch( MsgType(msg) ) {
				case AC_OPEN:   acc_open( (int *)msg );
						break;
				
				case WM_TOPPED:
				case WM_NEWTOP:
					        Wm_Topped( ( int *)msg );
						doedit = can_edit( tree, edit_obj );
					        if( doedit && !cursor )
					        {
					           objc_edit( tree, edit_obj, 0, (int *)&idx, ED_INIT );
						   cursor = TRUE;
					        }
						break;
						
				case WM_SIZED:
					doedit = can_edit( tree, edit_obj );
					
				/* fall through */
				case WM_MOVED:	/* if moving, that means we are on top, therefore, cursor is already on */
						doedit = can_edit( tree, edit_obj );
						if( !doedit )
							cursor = FALSE;
				case WM_REDRAW:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				/* redraw 'n' shit */
						
					if( edit_obj && ( msg[0] == WM_REDRAW ))
					{
					    NoEdit( edit_obj );
					    rect = ObRect( edit_obj );
					    objc_offset( tree, edit_obj, &rect.g_x, &rect.g_y );

					    /* The offsets will take care of the blinking cursor
					     * area that needs to be redraw to erase it.
					     */
					    rect.g_y -= 3;
					    rect.g_w += 3;
					    rect.g_h += 6;

					    /* Clip the rectangle to the work area of the form.*/
					    rc_intersect( &w.work, &rect ); 

					    /* The redraw is necessary to turn off the blinking cursor.
					     * We are going to need to send a redraw message to the calling
					     * cpx in case they have any custom redraws that need to be done.
					     */
					    do_redraw( tree, &rect ); 
					    
					    if( msg[0] == WM_REDRAW )
					    {	
					       for( idx = 0; idx < 8; idx++ )
						   puntmsg[idx] = msg[idx];
					    }

					}
					/* Here we redraw/move the area that is dirtied */    
					do_windows( (int *)msg, (int *)&event );
					if( edit_obj )
					    MakeEditable( edit_obj );
					doedit = can_edit( tree, edit_obj );
					if( !doedit )
						cursor = FALSE;
					if( msg[0] == WM_REDRAW )
					{	
					   for( idx = 0; idx < 8; idx++ )
						   puntmsg[idx] = msg[idx];

					   if( _app )
					      wind_update( END_UPDATE );	/* 06/18/93 cjg */

					   return( -1 );
					}
				break;

				default:if( msg[0] == AC_CLOSE )
					   SetAccCloseState( TRUE );
					   
					if( msg[0] == AP_TERM )
					{
					    SetAccCloseState( TRUE );
					    msg[0] = AC_CLOSE;
					}

					if( msg[0] == WM_CLOSED )
					   SetWmCloseState( TRUE );
					   
					for( idx = 0; idx < 8; idx++ )
					      puntmsg[idx] = msg[idx];

					if( _app )
					    wind_update( END_UPDATE );		/* 06/18/93 cjg */

					return( -1 );
			}
		}


/*
 * What about hot keys?? AIEEE!!
 */
		if( EvKey() ) {

			/*
			 * form_keybd() encapsulated here
			 */
			direction = NODIR;
			switch( key ) {

				case K_RETURN:
				case K_ENTER:
					next_obj = 0;
					direction = DEFAULTDIR;
					break;

				case K_BACKTAB:
				case K_UP:
					direction = BACKWARD;
					break;

				case K_TAB:
				case K_DOWN:
					direction = FORWARD;
					break;
			}

			if( direction != NODIR ) {
				key = 0;
				next_obj = find_obj( tree, edit_obj, direction );
				if( (direction == DEFAULTDIR) && (next_obj != 0) ) {
					Objc_change( tree, next_obj, &w.work,
 				        ObState(next_obj)|SELECTED, TRUE );
					cont = FALSE;
				}
			}
			/*
			 * End of form_keybd()
			 */

			/* The above code clears 'key', therefore, we'll
			 * check key FIRST, then test the ASCII and 
			 * scancode
			 */
			if( key && ( !( key & 0xff ) )  )
			{
			  if( ( key != K_UP     )  &&
			      ( key != K_DOWN   )  &&
			      ( key != K_RIGHT  )  &&
			      ( key != K_LEFT   )  &&
			      ( key != K_RETURN )  &&
			      ( key != K_ENTER  )  &&
			      ( key != K_TAB )	   &&
			      ( key != K_BACKTAB)
			    )
			    {
			      puntmsg[0] = CT_KEY;
			      puntmsg[3] = key;

			      if( _app )
			          wind_update( END_UPDATE );	/* 06/18/93 cjg */

			      return( -1 );
			    }  
			}

			if( key && doedit )
				objc_edit( tree, edit_obj, key, (int *)&idx, ED_CHAR );
		}

		if( EvButton() ) {
			next_obj = objc_find( tree, ROOT, MAX_DEPTH, m.x, m.y );
			if( next_obj == NIL ) {
				Bconout( 2, 7 );
				next_obj = 0;
			} else {
				cont = fm_button( tree, next_obj, clicks, &next_obj );
			}
		}

		if(  doedit && (!cont || (next_obj != 0)) && ( next_obj != edit_obj) )
		{
		   objc_edit( tree, edit_obj, 0, (int *)&idx, ED_END );
		   cursor = FALSE;
		}

		if( _app )   		
		   wind_update( END_UPDATE );	/* cjg 06/18/93 */
	}

	return next_obj;
}
Пример #20
0
Файл: main.c Проект: sctb/em
int
main(int argc, char **argv)
{
	char		*cp, *init_fcn_name = NULL;
	PF		 init_fcn = NULL;
	int	 	 o, i, nfiles;
	struct buffer	*bp = NULL;

	while ((o = getopt(argc, argv, "f:")) != -1)
		switch (o) {
		case 'f':
			if (init_fcn_name != NULL)
				errx(1, "cannot specify more than one "
				    "initial function");
			init_fcn_name = optarg;
			break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	setlocale(LC_CTYPE, "");

	maps_init();		/* Keymaps and modes.		*/
	funmap_init();		/* Functions.			*/

	if (init_fcn_name &&
	    (init_fcn = name_function(init_fcn_name)) == NULL)
		errx(1, "Unknown function `%s'", init_fcn_name);

	vtinit();		/* Virtual terminal.		*/
	dirinit();		/* Get current directory.	*/
	edinit(bp);		/* Buffers, windows.		*/
	bellinit();		/* Audible and visible bell.	*/

	/*
	 * doing update() before reading files causes the error messages from
	 * the file I/O show up on the screen.	(and also an extra display of
	 * the mode line if there are files specified on the command line.)
	 */
	update(CMODE);

	/* Force FFOTHARG=1 so that this mode is enabled, not simply toggled */
	if (init_fcn)
		init_fcn(FFOTHARG, 1);

	for (nfiles = 0, i = 0; i < argc; i++) {
		if (argv[i][0] == '+' && strlen(argv[i]) >= 2) {
			long lval;
			char *end;

			lval = strtol(&argv[i][1], &end, 0);
			if (argv[i][1] == '\0' || *end != '\0')
				goto notnum;
			startrow = lval;
		} else {
notnum:
			cp = adjustname(argv[i], FALSE);
			if (cp != NULL) {
				if (nfiles == 1)
					splitwind(0, 1);

				if ((curbp = findbuffer(cp)) == NULL) {
					vttidy();
					errx(1, "Can't find current buffer!");
				}
				(void)showbuffer(curbp, curwp, 0);
				if (readin(cp) != TRUE)
					killbuffer(curbp);
				else {
					/* Ensure enabled, not just toggled */
					if (init_fcn_name)
						init_fcn(FFOTHARG, 1);
					nfiles++;
				}
			}
		}
	}

	if (nfiles > 2)
		listbuffers(0, 1);

	/* fake last flags */
	thisflag = 0;
	for (;;) {
		if (epresf == KCLEAR)
			eerase();
		if (epresf == TRUE)
			epresf = KCLEAR;
		if (winch_flag) {
			do_redraw(0, 0, TRUE);
			winch_flag = 0;
		}
		update(CMODE);
		lastflag = thisflag;
		thisflag = 0;

		switch (doin()) {
		case TRUE:
			break;
		case ABORT:
			ewprintf("Quit");
			/* FALLTHRU */
		case FALSE:
		default:
			macrodef = FALSE;
		}
	}
}
Пример #21
0
/* cpx_call()
 * ======================================================================
 * Called ONLY when the CPX is being executed. Note that it is CPX_INIT()
 * that returned the ptr to cpx_call().
 * CPX_CALL() is the entry point to displaying and manipulating the
 * dialog box.
 *
 * IN: GRECT *rect:	Ptr to a GRECT that describes the current work
 *			area of the XControl window.
 *
 * OUT:
 *   FALSE:     The CPX has exited and no more messages are
 *		needed.  XControl will either return to its
 *		main menu or close its windows.
 *		This is used by XForm_do() type CPXs.
 *
 *   TRUE:	The CPX requests that XCONTROL continue to
 *		send AES messages.  This is used by Call-type CPXs.
 */
BOOLEAN
cdecl cpx_call( GRECT *rect )
{
     int   button;
     int   quit = 0;
     WORD  msg[8], clip[4];
     MRETS mk;
     int   ox, oy;
     
     ad_tree = (OBJECT *)rs_trindex[ COLOR ];
     ActiveTree( ad_tree );

     Wind_get(0, WF_WORKXYWH, (WARGS *)&desk );	/* set clipping to */
     rc_2xy( &desk, clip );			/*   Desktop space */

     open_vwork();
     vs_clip( vhandle, 1, ( int *)clip );
     
     ObX( ROOT ) = rect->g_x;
     ObY( ROOT ) = rect->g_y;
     Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
     draw_boxes();								/* draw the color boxes */
     outline( curbox, HILITE );		/* show selected box */
     close_vwork();
     
     do
     {
	button = (*xcpb->Xform_do)( tree, 0, msg );
     	switch( button )
     	{
	   case CCANCEL:
		         cnclchgs();			/* cancel all changes made */
     	
     	   case C*K: quit = TRUE;
     	   	     Deselect( button );
     	   	     break;

 	   case CRELOAD:		/* reload saved user-preference */
 	   		if( bpg )
 	   		{
	   		  if( saved )
	   		     init(&usr_vals);
	   		  else
	   		     init(&def_vals);
		          update_rgb(1);	/* update RGB on screen */
		        }   
	   		Deselect( button );
	   		Objc_draw( tree, button, MAX_DEPTH, NULL );
			break;


	   case CSAVE:	/* save current values */
	   		if( bpg )
	   		{
			  if ((*xcpb->XGen_Alert)(SAVE_DEFAULTS) == TRUE)
			  {
			    (*xcpb->MFsave)(MFSAVE, &orig_mf);
			    graf_mouse( BUSYBEE, 0L );
					
			    if( bpg )			/* if color */
			    {
				savergb();		/* save color info */
							/* update RGBs */
				cpyrgb((RGB *)&oldrgb, (RGB *)&newrgb, numcol );	
			    }

			    /* save current data to file */
			    saved = 1;
			    (*xcpb->CPX_Save)((void *)&saved, sizeof(DEFAULTS)+2);
	    		    (*xcpb->MFsave)(MFRESTORE, &orig_mf);
			  }
			}  
			Deselect( button );
			Objc_draw( tree, button, MAX_DEPTH, NULL );
	   		break;


	   case CUP:
	   		(*xcpb->Sl_arrow)(tree, CBASE, CSLIDE, CUP, -1, 
	    			col_max, col_min, &curcol, VERTICAL, nxtrow);
	    		break;
	    		
	   case CDOWN:
	    		(*xcpb->Sl_arrow)(tree, CBASE, CSLIDE, CDOWN, 1, 
	    			col_max, col_min, &curcol, VERTICAL, nxtrow);
	    		break;

   	   case CSLIDE:
			(*xcpb->MFsave)(MFSAVE, &orig_mf);
			graf_mouse( FLAT_HAND, 0L );
	    		(*xcpb->Sl_dragy)(tree, CBASE, CSLIDE, col_max, 
	    			col_min, &curcol, nxtgrp);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
			break;

	   case CBASE:
    			Graf_mkstate(&mk);
    			objc_offset(tree, CSLIDE, &ox, &oy);
    			if(mk.y < oy)
    	   		    oy = -col_page;
       			else
    	    		    oy = col_page;
			curslid = CSLIDE;
	    		(*xcpb->Sl_arrow)(tree, CBASE, CSLIDE, -1, oy, 
	    			col_max, col_min, &curcol, VERTICAL, nxtpage);
	    		break;


	   case RUP:
			curslid = RSLIDE;
	    		(*xcpb->Sl_arrow)(tree, RBASE, RSLIDE, RUP, 1, 0, 
	    			1000, &curscrn[R], VERTICAL, adjcol);
	    		break;
	    		
	   case RDOWN:
			curslid = RSLIDE;
	    		(*xcpb->Sl_arrow)(tree, RBASE, RSLIDE, RDOWN, -1, 
	    			0, 1000, &curscrn[R], VERTICAL, adjcol);
	    		break;
	    		
	   case RSLIDE:
			(*xcpb->MFsave)(MFSAVE, &orig_mf);
			graf_mouse( FLAT_HAND, 0L );
			curslid = RSLIDE;
	    		(*xcpb->Sl_dragy)(tree, RBASE, RSLIDE, 0, 1000, 
	    			&curscrn[R], adjcol);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
	    		
	   case RBASE:
    	   		Graf_mkstate(&mk);
    	   		objc_offset(tree, RSLIDE, &ox, &oy);
    	   		if( mk.y < oy)
    	   		     oy = VAL_PAGE;
    	   		else
    	       		     oy = -VAL_PAGE;
			curslid = RSLIDE;
	    		(*xcpb->Sl_arrow)(tree, RBASE, RSLIDE, -1, oy, 0, 
	    			1000, &curscrn[R], VERTICAL, adjcol);
	    		break;
	        
  	   case GUP:
			curslid = GSLIDE;
	    		(*xcpb->Sl_arrow)(tree, GBASE, GSLIDE, GUP, 1, 0, 
	    			1000, &curscrn[G], VERTICAL, adjcol);
	    		break;
	    		
	   case GDOWN:
			curslid = GSLIDE;
	    		(*xcpb->Sl_arrow)(tree, GBASE, GSLIDE, GDOWN, -1, 
	    			0, 1000, &curscrn[G], VERTICAL, adjcol);
	    		break;
	    		
	   case GSLIDE:
			(*xcpb->MFsave)(MFSAVE, &orig_mf);
			graf_mouse( FLAT_HAND, 0L );
			curslid = GSLIDE;
	    		(*xcpb->Sl_dragy)(tree, GBASE, GSLIDE, 0, 1000, 
	    			&curscrn[G], adjcol);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
	    		
	   case GBASE:
    	   		Graf_mkstate(&mk);
    	   		objc_offset(tree, GSLIDE, &ox, &oy);
    	   		if(mk.y < oy)
    	   		     oy = VAL_PAGE;
    	   		else
    	   	    	     oy = -VAL_PAGE;
			curslid = GSLIDE;
	    		(*xcpb->Sl_arrow)(tree, GBASE, GSLIDE, -1, oy, 0, 
	    			1000, &curscrn[G], VERTICAL, adjcol);
	    		break;
	   
	        
	   case BUP:
			curslid = BSLIDE;
	    		(*xcpb->Sl_arrow)(tree, BBASE, BSLIDE, BUP, 1, 0, 
	    			1000, &curscrn[B], VERTICAL, adjcol);
	    		break;
	    		
	   case BDOWN:
			curslid = BSLIDE;
	    		(*xcpb->Sl_arrow)(tree, BBASE, BSLIDE, BDOWN, -1, 
	    			0, 1000, &curscrn[B], VERTICAL, adjcol);
	    		break;
	    		
	   case BSLIDE:
			(*xcpb->MFsave)(MFSAVE, &orig_mf);
			graf_mouse( FLAT_HAND, 0L );
			curslid = BSLIDE;
	    		(*xcpb->Sl_dragy)(tree, BBASE, BSLIDE, 0, 1000, 
	    			&curscrn[B], adjcol);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
	    		
	   case BBASE:
    			Graf_mkstate(&mk);
    			objc_offset(tree, BSLIDE, &ox, &oy);
    			if(mk.y < oy)
	  		   oy = VAL_PAGE;
    			else
			   oy = -VAL_PAGE;
			curslid = BSLIDE;
	    		(*xcpb->Sl_arrow)(tree, BBASE, BSLIDE, -1, oy, 0, 
	    			1000, &curscrn[B], VERTICAL, adjcol);
	    		break;


  	   case TWO01:		/* for ST High rez */
	   case TWO02:
	
	   case FOUR01:		/* for ST Medium rez */
	   case FOUR02:
	   case FOUR03:
	   case FOUR04:
		
	   case BOX0:    	/* for all other rez */
	   case BOX1:
	   case BOX2:
	   case BOX3:
	   case BOX4:
	   case BOX5:
	   case BOX6:
	   case BOX7:
	   case BOX8:
	   case BOX9:
	   case BOX10:
	   case BOX11:
	   case BOX12:
	   case BOX13:
	   case BOX14:
	   case BOX15:
	  		if( button != curbox)	/* select requested color */
	  		{
			    curcol = button - headbox + headcol;
			    nxt_to_show(0);
			    update_slid( CBASE, CSLIDE, curcol, col_max, col_min, 1);
			}
	   		break;

     	   default:	if( button == -1 )
     			{
     			   switch( msg[0] )
     			   {
     			     case WM_REDRAW: /* redraw the cpx */
		  			     do_redraw((GRECT *)&msg[4], (int *)clip);
     			     		     break;
     			     		     
     			     case AC_CLOSE:  /* treated like a cancel */
	 				     cnclchgs();	/* cancel changes made */
     			     case WM_CLOSED: quit = TRUE; 	/* treated like an OK */
					     break;
					     
			     case CT_KEY:
			     	switch( msg[3] )	/* check which key is returned */
			     	{
					case UNDO:				/* if Undo key */
						if( bpg )			/* if there is color */
						{
						   cnclbnk();		/* cancel color changes */
						   update_rgb(1);	/* update RGB on screen */
						}
						break;
						
					case HOME:				/* if Clr Home key */
						if( bpg )
						{
						   init(&def_vals);	/* init to system defs */
						   update_rgb(1);	/* update RGB on screen */
						}   
						break;
				}

			     		     break;		     
     			     default:
     			     		break;
     			   }
     			}
     			break;
     	}
     }while( !quit);
     return( FALSE );
}
Пример #22
0
int
main(int argc, char **argv)
{
	char		*cp, *init_fcn_name = NULL;
	PF		 init_fcn = NULL;
	int	 	 o, i, nfiles;
	int	  	 nobackups = 0;
	struct buffer	*bp = NULL;

#ifdef MRUBY
	mrb_mg_init();
	int noinitfile = 0;
#endif /* MRUBY */

	while ((o = getopt(argc, argv, "nf:q")) != -1)
		switch (o) {
		case 'n':
			nobackups = 1;
			break;
		case 'f':
			if (init_fcn_name != NULL)
				errx(1, "cannot specify more than one "
				    "initial function");
			init_fcn_name = optarg;
			break;
		case 'q':
		     noinitfile = 1;
		     break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	maps_init();		/* Keymaps and modes.		*/
	funmap_init();		/* Functions.			*/

	/*
	 * This is where we initialize standalone extensions that should
	 * be loaded dynamically sometime in the future.
	 */
	{
		extern void grep_init(void);
		extern void theo_init(void);
		extern void cmode_init(void);
		extern void dired_init(void);

		dired_init();
		grep_init();
		theo_init();
		cmode_init();

#ifdef UTF8
		utf8_init();
#endif /* UTF8 */
	}

	if (init_fcn_name &&
	    (init_fcn = name_function(init_fcn_name)) == NULL)
		errx(1, "Unknown function `%s'", init_fcn_name);

	vtinit();		/* Virtual terminal.		*/
	dirinit();		/* Get current directory.	*/
	edinit(bp);		/* Buffers, windows.		*/
	ttykeymapinit();	/* Symbols, bindings.		*/

	/*
	 * doing update() before reading files causes the error messages from
	 * the file I/O show up on the screen.	(and also an extra display of
	 * the mode line if there are files specified on the command line.)
	 */
	update();

	/* user startup file */
#ifdef MRUBY
	if (noinitfile == 0 && (cp = startupfile(NULL)) != NULL)
		mrb_mg_load(cp);
#else
	if ((cp = startupfile(NULL)) != NULL)
		(void)load(cp);
#endif /* MRUBY */

	/* 
	 * Now ensure any default buffer modes from the startup file are
	 * given to any files opened when parsing the startup file.
	 * Note *scratch* will also be updated.
	 */
	for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
		bp->b_flag = defb_flag;
		for (i = 0; i <= defb_nmodes; i++) {
                	bp->b_modes[i] = defb_modes[i];
        	}
	}

	/* Force FFOTHARG=1 so that this mode is enabled, not simply toggled */
	if (init_fcn)
		init_fcn(FFOTHARG, 1);

	if (nobackups)
		makebkfile(FFARG, 0);

	for (nfiles = 0, i = 0; i < argc; i++) {
		if (argv[i][0] == '+' && strlen(argv[i]) >= 2) {
			long long lval;
			const char *errstr;

			lval = strtonum(&argv[i][1], INT_MIN, INT_MAX, &errstr);
			if (argv[i][1] == '\0' || errstr != NULL)
				goto notnum;
			startrow = lval;
		} else {
notnum:
			cp = adjustname(argv[i], FALSE);
			if (cp != NULL) {
				if (nfiles == 1)
					splitwind(0, 1);

				if ((curbp = findbuffer(cp)) == NULL) {
					vttidy();
					errx(1, "Can't find current buffer!");
				}
				(void)showbuffer(curbp, curwp, 0);
				if (readin(cp) != TRUE)
					killbuffer(curbp);
				else {
					/* Ensure enabled, not just toggled */
					if (init_fcn_name)
						init_fcn(FFOTHARG, 1);
					nfiles++;
				}
			}
		}
	}

	if (nfiles > 2)
		listbuffers(0, 1);

	/* fake last flags */
	thisflag = 0;
	for (;;) {
		if (epresf == KCLEAR)
			eerase();
		if (epresf == TRUE)
			epresf = KCLEAR;
		if (winch_flag) {
			do_redraw(0, 0, TRUE);
			winch_flag = 0;
		}
		update();
		lastflag = thisflag;
		thisflag = 0;

		switch (doin()) {
		case TRUE:
			break;
		case ABORT:
			ewprintf("Quit");
			/* FALLTHRU */
		case FALSE:
		default:
			ttbeep();
			macrodef = FALSE;
		}
	}
}
Пример #23
0
static void
on_renderer_queue_draw (GtkSourceGutterRenderer *renderer,
                        GtkSourceGutter         *gutter)
{
	do_redraw (gutter);
}
Пример #24
0
	WORD
col_pa_pref( )
{
	REG OBJECT	*obj;
	REG WORD	ret;
	REG WINDOW	*win;
	LONG		newwin;
	LONG		newdesk;
	LONG		*outpat;
	WORD		last,i,j;
	
	obj = get_tree( SSCREEN );

	newdesk = background[0].ob_spec;
	newwin = (UWORD)windspec;
					/* set the background pattern */
	last = ret = obj[DESKPREF].ob_state & SELECTED ? DESKPREF : WINPREF;

	for ( j = COLOR0,i = d_maxcolor; i < 16; i++ )
	  obj[j+i].ob_flags |= HIDETREE;	

	fm_draw( SSCREEN );

	goto c_1;
	
	while( TRUE )
	{
	  ret = xform_do( obj, 0 );
c_1:
	  if ( ret == SOK )
	    break;

	  if ( ret == SCANCEL )
	  {
	    do_finish( SSCREEN );
	    return;
	  }

	  if ( ret == DESKPREF )
	  {
	    outpat = &newdesk;
	    obj[DESKPREF].ob_state = SELECTED;
	    obj[WINPREF].ob_state = NORMAL;
	    goto c_2;
	  }
		    
	  if ( ret == WINPREF )
	  {
	    outpat = &newwin;
	    obj[WINPREF].ob_state = SELECTED;
	    obj[DESKPREF].ob_state = NORMAL;
c_2:
	    draw_fld( obj, DESKPREF );
	    draw_fld( obj, WINPREF );
	    obj[PATTERN].ob_spec = *outpat;
	  }

	  if ( ( ret >= PAT0 ) && ( ret <= PAT7 ) )
	  {
	    obj[PATTERN].ob_spec &= 0xFFFFFF0FL;
	    obj[PATTERN].ob_spec |= obj[ret].ob_spec & 0x000000F0L;	
	  }
	  else				/* color changed	*/
	  if ( ( ret >= COLOR0 ) && ( ret <= COLOR15 ) )
	  {
	    obj[PATTERN].ob_spec &= 0xFFFFFFF0L;
	    obj[PATTERN].ob_spec |= obj[ret].ob_spec & 0x0000000FL;
	  }

	  objc_draw( obj, OUTBOX, 2, 0, 0, full.w, full.h );
	  *outpat = obj[PATTERN].ob_spec;

	}/* while */

	do_finish( SSCREEN );

	if ( background[0].ob_spec != newdesk )
	{
	  background[0].ob_spec = newdesk;
	  do_redraw( 0, &full, 0 );
	}

	win = winhead;

	if ( windspec != (UWORD)newwin )
	{
	  windspec = (UWORD)newwin;
	  while( win )
	  {
	    if ( win->w_obj )	/* fixed 7/7/92	*/
	      win->w_obj[0].ob_spec = windspec;
	    win = win->w_next;
	  }

	  win = w_gfirst();
	  while( win )
	  {
	    do_redraw( win->w_id, &full, 0 );
	    win = w_gnext();
	  }
	}
}
Пример #25
0
static gboolean
redraw_for_window (GtkSourceGutter *gutter,
                   GdkEventAny     *event,
                   gboolean         act_on_window,
                   gint             x,
                   gint             y)
{
	Renderer *at_x = NULL;
	GList *item;
	gboolean redraw;
	gint start;

	if (event->window != gtk_source_gutter_get_window (gutter) && act_on_window)
	{
		return FALSE;
	}

	if (act_on_window)
	{
		at_x = renderer_at_x (gutter, x, &start, NULL);
	}

	redraw = FALSE;

	for (item = gutter->priv->renderers; item; item = g_list_next (item))
	{
		Renderer *renderer = item->data;
		gint prelit = renderer->prelit;

		if (!gtk_source_gutter_renderer_get_visible (renderer->renderer))
		{
			renderer->prelit = -1;
		}
		else
		{
			if (renderer != at_x || !act_on_window)
			{
				renderer->prelit = -1;
			}
			else if (renderer_query_activatable (gutter,
			                                     renderer,
			                                     (GdkEvent *)event,
			                                     x,
			                                     y,
			                                     NULL,
			                                     NULL,
			                                     start))
			{
				renderer->prelit = y;
			}
			else
			{
				renderer->prelit = -1;
			}
		}

		redraw |= (renderer->prelit != prelit);
	}

	if (redraw)
	{
		do_redraw (gutter);
	}

	return FALSE;
}
Пример #26
0
/* 
 * Show color panel
 * Passed:  GRECT *rect		= pointer to rectangle CPX resides in 
 * Returns: BOOLEAN	FALSE	= to exit CPX
 */
BOOLEAN	
cdecl  colpnl(GRECT *rect)
{
    MRETS mk;
    int quit=0;
    int obj, ox, oy;
    WORD msg[8], clip[4];
	GRECT obrect;		/* object rectangle */
    
    
    Wind_get(0, WF_WORKXYWH, (WARGS *)&obrect);	/* set clipping to */
    rc_2xy(&obrect, clip);						/*   Desktop space */
    
    open_vwork();
    vs_clip(vhandle, 1, (int *)clip);
    
  	ObX(COLPNL) = rect->g_x;					/* position panel */
 	ObY(COLPNL) = rect->g_y;
    Objc_draw(tree, COLPNL, MAX_DEPTH, NULL);	/* draw panel */
   	draw_boxes();								/* draw the color boxes */
   	outline(curbox, HILITE);					/* show selected box */
    close_vwork();
    
    if (IsSelected(INVRSVDO))	/* if Invert button is selected */
    	Deselect(INVRSVDO);		/* deselect it */
    	
    do {
    if ((obj = (*xcpb->Xform_do)(tree, COLPNL, msg)) != -1) {
    	obj &= 0x7fff;				/* mask out double clicks */
 		switch(obj) {
			case RUP:
				curslid = RSLID;
	    		(*xcpb->Sl_arrow)(tree, RBASE, RSLID, RUP, 1, val_min, 
	    			val_max, &curscrn[R], VERTICAL, adjcol);
	    		break;
			case RDOWN:
				curslid = RSLID;
	    		(*xcpb->Sl_arrow)(tree, RBASE, RSLID, RDOWN, -1, 
	    			val_min, val_max, &curscrn[R], VERTICAL, adjcol);
	    		break;
			case RSLID:
				(*xcpb->MFsave)(MFSAVE, &orig_mf);
				if( AES_Version >= 0x0320 )
				    DRAG_MOUSE;
				curslid = RSLID;
	    		(*xcpb->Sl_dragy)(tree, RBASE, RSLID, val_min, val_max, 
	    			&curscrn[R], adjcol);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
			case RBASE:
    	   		Graf_mkstate(&mk);
    	   		objc_offset(tree, RSLID, &ox, &oy);
    	   		if(mk.y < oy)
    	   			oy = VAL_PAGE;
    	   		else
    	       		oy = -VAL_PAGE;
				curslid = RSLID;
	    		(*xcpb->Sl_arrow)(tree, RBASE, RSLID, -1, oy, val_min, 
	    			val_max, &curscrn[R], VERTICAL, adjcol);
	    		break;
	        
			case GUP:
				curslid = GSLID;
	    		(*xcpb->Sl_arrow)(tree, GBASE, GSLID, GUP, 1, val_min, 
	    			val_max, &curscrn[G], VERTICAL, adjcol);
	    		break;
			case GDOWN:
				curslid = GSLID;
	    		(*xcpb->Sl_arrow)(tree, GBASE, GSLID, GDOWN, -1, 
	    			val_min, val_max, &curscrn[G], VERTICAL, adjcol);
	    		break;
			case GSLID:
				(*xcpb->MFsave)(MFSAVE, &orig_mf);
				if( AES_Version >= 0x0320 )
				    DRAG_MOUSE;
				curslid = GSLID;
	    		(*xcpb->Sl_dragy)(tree, GBASE, GSLID, val_min, val_max, 
	    			&curscrn[G], adjcol);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
			case GBASE:
    	   		Graf_mkstate(&mk);
    	   		objc_offset(tree, GSLID, &ox, &oy);
    	   		if(mk.y < oy)
    	   			oy = VAL_PAGE;
    	   		else
    	   	    	oy = -VAL_PAGE;
				curslid = GSLID;
	    		(*xcpb->Sl_arrow)(tree, GBASE, GSLID, -1, oy, val_min, 
	    			val_max, &curscrn[G], VERTICAL, adjcol);
	    		break;
	        
			case BUP:
				curslid = BSLID;
	    		(*xcpb->Sl_arrow)(tree, BBASE, BSLID, BUP, 1, val_min, 
	    			val_max, &curscrn[B], VERTICAL, adjcol);
	    		break;
			case BDOWN:
				curslid = BSLID;
	    		(*xcpb->Sl_arrow)(tree, BBASE, BSLID, BDOWN, -1, 
	    			val_min, val_max, &curscrn[B], VERTICAL, adjcol);
	    		break;
			case BSLID:
				(*xcpb->MFsave)(MFSAVE, &orig_mf);
				if( AES_Version >= 0x0320 )
				    DRAG_MOUSE;
				curslid = BSLID;
	    		(*xcpb->Sl_dragy)(tree, BBASE, BSLID, val_min, val_max, 
	    			&curscrn[B], adjcol);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
			case BBASE:
    			Graf_mkstate(&mk);
    			objc_offset(tree, BSLID, &ox, &oy);
    			if(mk.y < oy)
    	  				oy = VAL_PAGE;
    			else
					oy = -VAL_PAGE;
				curslid = BSLID;
	    		(*xcpb->Sl_arrow)(tree, BBASE, BSLID, -1, oy, val_min, 
	    			val_max, &curscrn[B], VERTICAL, adjcol);
	    		break;
	    		
	    	case COLUP:
	    		(*xcpb->Sl_arrow)(tree, COLBASE, COLSLID, COLUP, -1, 
	    			col_max, col_min, &curcol, VERTICAL, nxtrow);
	    		break;
			case COLDOWN:
	    		(*xcpb->Sl_arrow)(tree, COLBASE, COLSLID, COLDOWN, 1, 
	    			col_max, col_min, &curcol, VERTICAL, nxtrow);
	    		break;
			case COLSLID:
				(*xcpb->MFsave)(MFSAVE, &orig_mf);
				if( AES_Version >= 0x0320 )
				    DRAG_MOUSE;
	    		(*xcpb->Sl_dragy)(tree, COLBASE, COLSLID, col_max, 
	    			col_min, &curcol, nxtgrp);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
			case COLBASE:
    			Graf_mkstate(&mk);
    			objc_offset(tree, COLSLID, &ox, &oy);
    			if(mk.y < oy)
    	   			oy = -col_page;
       			else
    	    		oy = col_page;
				curslid = COLSLID;
	    		(*xcpb->Sl_arrow)(tree, COLBASE, COLSLID, -1, oy, 
	    			col_max, col_min, &curcol, VERTICAL, nxtpage);
	    		break;
	    
			case BNKRIGHT:
	    		(*xcpb->Sl_arrow)(tree, BNKBASE, BNKSLID, BNKRIGHT, 1, 
	    			BNK_MIN, BNK_MAX, &curbnk, HORIZONTAL, nxtbnk);
	    		break;
			case BNKLEFT:
	    		(*xcpb->Sl_arrow)(tree, BNKBASE, BNKSLID, BNKLEFT, -1, 
	    			BNK_MIN, BNK_MAX, &curbnk, HORIZONTAL, nxtbnk);
	    		break;
			case BNKSLID:
				(*xcpb->MFsave)(MFSAVE, &orig_mf);
				if( AES_Version >= 0x0320 )
				    DRAG_MOUSE;
	    		(*xcpb->Sl_dragx)(tree, BNKBASE, BNKSLID, BNK_MIN, 
	    			BNK_MAX, &curbnk, nxtbnk);
	    		(*xcpb->MFsave)(MFRESTORE, &orig_mf);
	    		break;
			case BNKBASE:
    			Graf_mkstate(&mk);
    			objc_offset(tree, BNKSLID, &ox, &oy);
    			if(mk.x < ox)
    	   			oy = -BNK_PAGE;
    			else
    	    		oy = BNK_PAGE;
	    		(*xcpb->Sl_arrow)(tree, BNKBASE, BNKSLID, -1, oy, 
	    			BNK_MIN, BNK_MAX, &curbnk, HORIZONTAL, nxtbnk);
	    		break;
	
			case DUO0:			/* for ST High rez */
			case DUO1:
	
			case QUARTRO0:		/* for ST Medium rez */
			case QUARTRO1:
			case QUARTRO2:
			case QUARTRO3:
		
			case BOX0:    		/* for all other rez */
			case BOX1:
			case BOX2:
			case BOX3:
			case BOX4:
			case BOX5:
			case BOX6:
			case BOX7:
			case BOX8:
			case BOX9:
			case BOX10:
			case BOX11:
			case BOX12:
			case BOX13:
			case BOX14:
			case BOX15:
				if (obj != curbox) {	/* select requested color */
					curcol = obj - headbox + headcol;
					nxt_to_show(0);
					update_slid(VERTICAL, COLBASE, COLSLID, curcol, 
						col_max, col_min, 1);
				}
	   			break;
	    
	   		case INVRSVDO:
	   			Deselect(obj);				/* deselect button */
				flip(0, &curinv);			/* read invert state */
	   			if (curinv & NOT_FLIPPED) {	/* inverted? */
	   				curinv &= 0xfffe;		/* if not, invert it */
	   			} else {					/* else */
	   				curinv |= NOT_FLIPPED;	/* restore it */
	   				draw_button(obj);		/* redraw button */
	   			}
	   			flip(1, &curinv);			/* set new invert state */
	   			
	   			if (bpg) {						/* if color */
	   				swaprgb(curnew, curnew+1);	/* swap pen 0 and 1 */
	   				open_vwork();
	   				vs_color(vhandle, 0, (int *)curnew);
	   				vs_color(vhandle, 1, (int *)(curnew+1));
	   				close_vwork();
	   				*curdirt = *(curdirt+1) = *touch_bnk = DIRTY;
	   				update_rgb(1);			/* update RGB sliders */
	   			}
	   			break;
	    
	   		case SETGRAY:
	   		case SETCOL:
	   			Deselect(obj);			/* deselect selected button */
	   			HideObj(obj);			/* hide selected button */
	   			if (obj == SETGRAY) {
	   				obj = SETCOL;		/* change to Color button */
	   				curgray = TRUE;		/* turn on hypermono */
	   			} else {
	   				obj = SETGRAY;		/* change to Gray button */
	   				curgray = FALSE;	/* turn off hypermono */
	   			}
	   			ShowObj(obj);			/* show new button */
	   			draw_button(obj);		/* draw it */
	   			Vsync();
	   			EsetGray(curgray);		/* set to selected mode */
	   			reinitcol();			/* reinit color regs */
	   			break;
	   				
			case COLSAVE:				/* save current values */
				if ((*xcpb->XGen_Alert)(SAVE_DEFAULTS) == TRUE) {
					(*xcpb->MFsave)(MFSAVE, &orig_mf);
					if( AES_Version >= 0x0320 )
					    BEE_MOUSE;
					
					if (bpg) {					/* if color */
						usr_vals.bnk = curbnk;	/* save bank # */
						savergb();				/* save color info */
												/* update RGBs */
						cpyrgb((RGB *)&oldrgb, (RGB *)&newrgb, totcol);	
					}
			
					if (currez == STHI)			/* if in ST high rez */
						usr_vals.inv = curinv;	/* save invert state */
					
					/* if hypermono supported, save state */
					if (curmode == TTVDO && currez != TTHI)
						usr_vals.gray = curgray;
		
					/* save current data to file */
					saved = 1;
					(*xcpb->CPX_Save)((void *)&saved, sizeof(DEFAULTS)+2);
					
	    			(*xcpb->MFsave)(MFRESTORE, &orig_mf);
				}
				Deselect(obj);
				draw_button(obj);	
	   			break;
	   	
			case COLCNCEL:
				cnclchgs();			/* cancel all changes made */
	   	
			case COLOK:				/* accept all changes made */
				Deselect(obj);				/* deselect button */
	   			quit = TRUE;				/* ready to quit */
	   			break;
	   			
	   		case COLRLOAD:			/* reload saved user-preference */
	   			if (saved)
	   				init(&usr_vals);
	   			else
	   				init(&def_vals);
	   			Deselect(obj);
	   			draw_button(obj);
	   			break;
	   	}
	} else {
		switch(msg[0]) {
			case WM_REDRAW:				/* redraw cpx */
				do_redraw((GRECT *)&msg[4], (int *)clip);
				break;
			
			case KEY_CODE:
				switch(msg[3]) {	/* check which key is returned */
					case UNDO:				/* if Undo key */
						/* reset to original invert state */
						if (currez == STHI && oldinv != curinv) {
							flip(1, &oldinv);
							if (!(oldinv & NOT_FLIPPED))
								Select(INVRSVDO);
							draw_button(INVRSVDO);
							Deselect(INVRSVDO);
							curinv = oldinv;
						}
						
						if (bpg) {			/* if there is color */
							if ((int)curmode == TTVDO && currez != TTHI
								&& curgray != oldgray) {
								Vsync();
								EsetGray(oldgray);
								reinitcol();
								if (oldgray) {
									HideObj(SETGRAY);
									obj = SETCOL;
								} else {
									HideObj(SETCOL);
									obj = SETGRAY;
								}
								ShowObj(obj);
								draw_button(obj);
								curgray = oldgray;
							}
							cnclbnk();		/* cancel color changes */
							update_rgb(1);	/* update RGB on screen */
						}
						break;
						
					case HOME:					/* if Clr Home key */
						if (currez != TTHI)		/* if not in TT High rez */
							init(&def_vals);	/* init to system defs */
						break;
				}
				break;
						
			case AC_CLOSE:
				cnclchgs();			/* cancel changes made */
					
			case WM_CLOSED:
				quit = TRUE;				/* ready to quit */
				break;
		}
	}
    } while (!quit);

    return (FALSE);
}
Пример #27
0
/* Redraw_XForm_Do()
 *==========================================================================
 * Handle a redraw message for XFORM_DO
 *
 * IN:   GRECT *rect:		 	Dirtied retangle area
 * OUT:  void
 *
 * GLOBAL:	OBJECT *cpx_tree:       object tree of xformdo cpx
 */
void
Redraw_XForm_Do( GRECT *rect )
{
   if( IsXCPXActive() )
        do_redraw( cpx_tree, ROOT, rect );
}
Пример #28
0
/*
 * Refresh the display.  A call is made to the "ttresize" entry in the
 * terminal handler, which tries to reset "nrow" and "ncol".  They will,
 * however, never be set outside of the NROW or NCOL range.  If the display
 * changed size, arrange that everything is redone, then call "update" to
 * fix the display.  We do this so the new size can be displayed.  In the
 * normal case the call to "update" in "main.c" refreshes the screen, and
 * all of the windows need not be recomputed. This call includes a
 * 'force' parameter to ensure that the redraw is done, even after a
 * a suspend/continue (where the window size parameters will already
 * be updated). Note that when you get to the "display unusable"
 * message, the screen will be messed up. If you make the window bigger
 * again, and send another command, everything will get fixed!
 */
int
redraw(int f, int n)
{
	return (do_redraw(f, n, FALSE));
}
Пример #29
0
/*
 * Get a single event, process it, and return.
 *
 */
domulti(){
    int event;
    
    event = evnt_multi(MU_MESAG,
			1,1,butdown,
			0,0,0,0,0,
			0,0,0,0,0,
			msgbuff,0,0,&mx,&my,&ret,&ret,&keycode,&ret);

    if (event & MU_MESAG) {
    	wind_update(TRUE);
	switch (msgbuff[0]) {
	    case WM_REDRAW:
		do_redraw(msgbuff[4],msgbuff[5],msgbuff[6],msgbuff[7]);
		break;

	    case MN_SELECTED:
	        BEE_MOUSE;
		switch(msgbuff[3]) {
		    case MNDISK:
			switch (msgbuff[4]) {
			    case DIFORM:
		        	if ((needscan) && (rescan(0,0) == ERROR))	{
						break;	/* don't report medium changed */
					}
			        tformat = TRUE;
					needscan = FALSE;
			        dodiform();
			        tformat = FALSE;
			        break;
			    case DIPART:
		        	if ((needscan)&&(rescan(0,0) == ERROR))	{
						break;	/* don't report medium changed */
					}
					needscan = FALSE;
			        dodipart(-1, NULL, NULL);
			    	break;
			    case DIZERO:
					if (pnf)	{
						err(needboot);
					} else {
		        		if ((needscan)&&(rescan(0,1) == ERROR))	{
							break;	/* don't report medium changed */
						}
						needscan = FALSE;
			        	dodizero();
					}
			        break;
			    case DIMARK:
					if (pnf)	{
						err(needboot);
					} else {
		        		if ((needscan)&&(rescan(0,1) == ERROR))	{
							break;	/* don't report medium changed */
						}
						needscan = FALSE;
			        	dodimark();
					}
			        break;
			    case DISHIP:
		        	if ((needscan)&&(rescan(0,0) == ERROR))	{
						break;	/* don't report medium changed */
					}
					needscan = FALSE;
			        dodiship();
			        break;
			    default:	    break;
			}
			break;

		    case MNFILE:
			switch (msgbuff[4]) {
			    case FIQUIT:
				running = 0;
				break;

			    default:
				break;
			}
			break;
			
		    case MNDESK:
			if(msgbuff[4] == DEABOUT) {
			    strcpy(abtdial[ABVERSN].ob_spec, "Version 3.5");
			    abtdial[ABOK].ob_state = NORMAL;
			    execform(abtdial);
			}
			break;		/* "cannot happen" */
		}

		menu_tnormal(menuobj, msgbuff[3], 1);	/* back to normal */
	        ARROW_MOUSE;
		break;
		
	    case WM_NEWTOP:
	    case WM_TOPPED:
		wind_set(wi_handle, WF_TOP, 0, 0, 0, 0);
		break;

	    case WM_CLOSED:
		running = FALSE;
		break;

	    default:
		break;
	}
	wind_update(FALSE);
    }
}
Пример #30
0
/* MAIN()
 * ================================================================
 */
VOID
main( VOID )
{
	WORD    button;
	BOOLEAN done;
	OBJECT  *tree;
       

	appl_init();

	phys_handle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );

	open_vwork();
	
        graf_mouse( ARROW, 0L );
        
        rsrc_load( "DEMO.RSC" );

        rsrc_gaddr( 0, MENUBAR, &ad_menubar );
        rsrc_gaddr( 0, ATREE, &ad_tree );
	rsrc_gaddr( 0, FONTTREE, &ad_fonts );
	rsrc_gaddr( 0, STREE, &ad_style );
	rsrc_gaddr( 0, POSTREE, &ad_position );
	rsrc_gaddr( 0, CTREE, &ad_color );
        rsrc_gaddr( 0, PTREE, &ad_pattern );
	rsrc_gaddr( 0, MTREE, &ad_modem );

	rsrc_gaddr( 0, BAUDRATE, &ad_baudrate );
	rsrc_gaddr( 0, PARTREE, &ad_parity );
	rsrc_gaddr( 0, BITTREE, &ad_bittree );
	rsrc_gaddr( 0, STOPTREE, &ad_stoptree );
	rsrc_gaddr( 0, PORTTREE, &ad_porttree );
	rsrc_gaddr( 0, FLOWTREE, &ad_flowtree );

	rsrc_gaddr( 0, LTREE, &ad_list );
	rsrc_gaddr( 0, TOOLBOX, &ad_tools );
	rsrc_gaddr( 0, BLANK, &ad_blank );
	rsrc_gaddr( 0, TOOLBOX2, &ad_box2 );
	rsrc_gaddr( 0, TOOLBAR, &ad_box3 );

	rsrc_gaddr( 0, FONT2, &ad_font2 );


	/* Attach all Submenus that are being attached */
	AttachMenus();


	/* CheckMark the Current Menu Items in their respective menus */
	menu_icheck( ad_baudrate, CurBaudRate, 1 );
	menu_icheck( ad_parity, CurParity, 1 );
	menu_icheck( ad_bittree, CurBits, 1 );
	menu_icheck( ad_stoptree, CurStopBits, 1 );
	menu_icheck( ad_porttree, CurPort, 1 );
	menu_icheck( ad_flowtree, CurFlow, 1 );

	menu_icheck( ad_style, CurStyle, 1 );
	menu_icheck( ad_position, CurPos, 1 );
	menu_icheck( ad_fonts, CurFonts, 1 );
	menu_icheck( ad_font2, CurFont2, 1 );

        /* display menubar stuff here */
        menu_bar( ad_menubar, TRUE );

	/* initialize windows */
        wind_get( 0, WF_FULLXYWH, &desk.g_x, &desk.g_y, &desk.g_w, &desk.g_h );
	cur_tree = ad_tools;
	menu_flag = TRUE;			/* Set Toggle Flags */
	SubFlag   = TRUE;
	ToolFlag  = TRUE;

	CurRect.g_x = desk.g_x;
	CurRect.g_y = desk.g_y;
	CurRect.g_w = 320;
	CurRect.g_h = 200;

	InitObjects();

	InitWindow();
	menu_ienable( ad_menubar, FOPEN, 0 );
	menu_ienable( ad_menubar, FCLOSE, 1 );



        done = FALSE;
	do
	{

	    evnt_mesag( msg );
	    
	    wind_update( BEG_UPDATE );

	    if( msg[0] == MN_SELECTED )
	    {
		/* msg[7] is the parent of FQUIT - which the user can't know */
		ptr = ( OBJECT **)&msg[5];
	if( *ptr == ad_menubar )
		{
		   switch( msg[4] )
		   {
		      case FQUIT:
				  button = form_alert( 1, "[1][ |  EXIT PROGRAM? ][OK|Cancel]");
				  if( button == 1 )
		 		      done = TRUE;
		       		  break;

		      case ABOUTX: execform( ad_tree, 0 );
				   break;

		      case PHONE: do_modem();
				  break;

		      case TABOUT: /* Enable, Disable About PLUS change TEXT */
				   menu_flag ^= 1;
				   menu_ienable( ad_menubar, ABOUTX, menu_flag );
				   menu_text( ad_menubar, TABOUT, TextAbout[ menu_flag ] );

				  if( menu_flag )
				    menu_text( ad_menubar, ABOUTX, "  About Demo...     " );
				  else
				    menu_text( ad_menubar, ABOUTX, "  Disabled...       " );
				  break;

		       case TSUB: /* Enable/Disable all Submenus */
				  SubFlag ^= 1;
				  menu_text( ad_menubar, TSUB, TextSubMenu[ SubFlag ] );
				  if( SubFlag )
				    AttachMenus();
				  else
				    DetachMenus();
				  break;

		       case SLISTS: DoList();			/* Do A Drop Down List Dialog */
				    break;

		       case TOOLFLAG: /* Enable/Disable ToolBox */
				      ToolFlag ^= 1;
				      menu_text( ad_menubar, TOOLFLAG, TextToolBox[ ToolFlag ] );
				      if( ToolFlag )
				      {
					*( (LONG *)&tree_data[0] ) = ( LONG )cur_tree;
					wind_set( wid, WF_TOOLBAR, tree_data[0], tree_data[1], dummy, dummy );
				      }
				      else
					wind_set( wid, WF_TOOLBAR, 0, 0, dummy, dummy );
				      break;

		        case SWITCH: /* Switch ToolBoxes */
					if( cur_tree == ad_tools )
					   cur_tree = ad_box2;
					else if( cur_tree == ad_box2 ) {
					         cur_tree = ad_box3;

					         ActiveTree( ad_fonts );
      						 textptr = ObString( CurFonts );
						 strncpy( &tbuff[0], &textptr[1], 28 );

      						 ActiveTree( ad_box3 );
      						 TedText( FBUTT1 ) = &tbuff[0];
					     }
					     else
					       cur_tree = ad_tools;
					*( (LONG *)&tree_data[0] ) = ( LONG )cur_tree;
					ToolFlag = TRUE;
	  	    		        menu_text( ad_menubar, TOOLFLAG, TextToolBox[ ToolFlag ] );
					wind_set( wid, WF_TOOLBAR, tree_data[0], tree_data[1], dummy, dummy );
				     break;

			case FCLOSE: /* close Window */
				     if( wid ) {
					wind_get( wid, WF_CURRXYWH,
						  &CurRect.g_x, &CurRect.g_y,
						  &CurRect.g_w, &CurRect.g_h );
			                wind_close( wid );
			                wind_delete( wid );
			                wid = 0;
					menu_ienable( ad_menubar, FCLOSE, 0 );
					menu_ienable( ad_menubar, FOPEN, 1 );
				     }
				     break;

			case FOPEN:  /* open Window */
				     if( !wid ) {
					InitWindow();
					menu_ienable( ad_menubar, FOPEN, 0 );
					menu_ienable( ad_menubar, FCLOSE, 1 );
				     }				 
				     break;

		      default:
				   break;
		   }
		}

		
		/* MENU SELECTED -> Font Style Menu Clicked on as a SUBMENU from the Menubar*/
		if( *ptr == ad_style )
		{
		   menu_icheck( ad_style, CurStyle, 0 );	/* Turn OFF Old Checkmark */
		   menu_icheck( ad_style, msg[4], 1 );		/* Turn ON New CheckMark  */
		   CurStyle = msg[4];				/* Update Current Var     */
		   menu_istart( 1, ad_style, ROOT, CurStyle );	/* Reset Starting Position*/
		}


		/* MENU SELECTED -> Font Position Clicked on as a SUBMENU from the menubar */
		if( *ptr == ad_position )
		{
		   menu_icheck( ad_position, CurPos, 0 );
		   menu_icheck( ad_position, msg[4], 1 );
		   CurPos = msg[4];
		   menu_istart( 1, ad_position, ROOT, CurPos );
		}


		/* MENU SELECTED -> Fonts Menu Clicked on as a SUBMENU from the menubar */
		if( *ptr == ad_fonts )
		{
		   menu_icheck( ad_fonts, CurFonts, 0 );
		   menu_icheck( ad_fonts, msg[4], 1 );
		   CurFonts = msg[4];
		   menu_istart( 1, ad_fonts, ROOT, CurFonts );
		}

		menu_tnormal( ad_menubar, msg[3], TRUE );
            }

	    if( msg[0] != MN_SELECTED ) {
		switch( msg[0] ) {
		   case WM_FULLED:
			DoFull( msg[3] );
			break;

		   case WM_REDRAW:
			 DoRedraw( msg );
			 break;

		   case WM_ARROWED:
		   case WM_HSLID:
		   case WM_VSLID:
			 break;

		   case WM_MOVED:
			 if( msg[3] == wid ) {
			    wind_set( wid, WF_CURRXYWH, msg[4],
				      msg[5], msg[6], msg[7] );
			 }
			 break;

		   case WM_TOPPED:
			 if( msg[3] == wid ) {
			    wind_set( wid, WF_TOP );
			 }
			 break;

		   case WM_CLOSED:
			 if( msg[3] == wid ) {
			    wind_get( wid, WF_CURRXYWH,
				      &CurRect.g_x, &CurRect.g_y,
				      &CurRect.g_w, &CurRect.g_h );

			    wind_close( wid );
			    wind_delete( wid );
			    wid = 0;
			    menu_ienable( ad_menubar, FCLOSE, 0 );
			    menu_ienable( ad_menubar, FOPEN, 1 );
			 }
			 break;

		   case WM_SIZED:
			DoSizer( msg );
			break;

		   case WM_TOOLBAR:
			if( msg[3] == wid ) {
			      /* Button Handling for ToolBox #1 */
			      if( cur_tree == ad_tools ) {
			        switch( msg[4] ) {
			           case T1B1:  button = B1B1;
				        break;
			           case T1B2:  button = B1B2;
				        break;
			           case T1B3:  button = B1B3;
				        break;
			           case T1B4:  button = B1B4;
				        break;
			           case T1B5:  button = B1B5;
				        break;
				}
			      }

			      /* Button Handling for TOOLBOX 2 */
			      if( cur_tree == ad_box2 ) {
			        switch( msg[4] ) {
			           case T2I1:  button = T2B1;
				        break;
			           case T2I2:  button = T2B2;
				        break;
			           case T2I3:  button = T2B3;
				        break;
			           case T2I4:  button = T2B4;
				        break;
			           case T2I5:  button = T2B5;
				        break;
				}
			      }

			      /* Word Processing Tree */
			      if( cur_tree == ad_box3 ) {
				switch( msg[4] ) {
				   case FBUTT1:
				   case FBUTT2: DoFonts();
						break;

				   default:
					    break;
				}
			      }



			   if( cur_tree != ad_box3 ) {
			     if( cur_tree[ button ].ob_state & SELECTED )
			       cur_tree[ button ].ob_state &= ~SELECTED;
			     else
			       cur_tree[ button ].ob_state |= SELECTED;

			     objc_offset( cur_tree, button, &r.g_x, &r.g_y );
			     r.g_x -= 2;
			     r.g_y -= 2;
			     r.g_w = cur_tree[ button ].ob_width + 4;
			     r.g_h = cur_tree[ button ].ob_height + 4;
			     do_redraw( cur_tree, button, &r );
			   }

			}  /* end of msg[3] == wid */
			break;

			case WM_ICONIFY:
			     if( msg[3] == wid )
			       wind_set( msg[3], WF_ICONIFY, msg[4], msg[5], msg[6], msg[7] );
			     break;

			case WM_UNICONIFY:
			     if( msg[3] == wid )
			       wind_set( msg[3], WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7] );
			     break;

		   default:
			break;
		}  /* end of switch */
	    }
	    wind_update( END_UPDATE );
	    	    
	}while( !done );
	if( wid > 0 )
	   wind_delete( wid );

        menu_bar( ad_menubar, FALSE );
	
	graf_mouse( ARROW, 0L );	
	
        rsrc_free();

       	close_vwork();
	appl_exit();
}