Beispiel #1
0
    void scroll_bar::
    b2_down (
    )
    {
        if (pos != max_pos)
        {
            set_slider_pos(pos+1);
            if (scroll_handler.is_set())
                scroll_handler();

            if (b2_timer.delay_time() == 1000)
                b2_timer.set_delay_time(500);
            else
                b2_timer.set_delay_time(50);
            b2_timer.start();
        }
    }
Beispiel #2
0
    void scroll_bar::
    b1_down (
    )
    {
        if (pos != 0)
        {
            set_slider_pos(pos-1);
            if (scroll_handler.is_set())
                scroll_handler();

            if (b1_timer.delay_time() == 1000)
                b1_timer.set_delay_time(500);
            else
                b1_timer.set_delay_time(50);
            b1_timer.start();
        }
    }
Beispiel #3
0
static bool select_font( bool is_prn )
{
int button, cx, cy, cw, ch, mousey, slidey, dum;
int index, i, double_click;
long pos;
static int top = 0;                 /* first name set to the top */

   wind_update(BEG_UPDATE);

   set_slider_size();                     /* set slider size and position, like a GEM window */
   set_slider_pos(top);

   ((TEDINFO *)chooser[CHACTION].ob_spec)->te_ptext = " Choose GDOS font ";
   ((TEDINFO *)chooser[CHTITLE].ob_spec)->te_ptext = is_prn? " Printer font list: ": " Screen font list: ";
   ((TEDINFO *)chooser[GEMFNAME].ob_spec)->te_ptext = gem_file_name;
   ((TEDINFO *)chooser[GEMFNAME].ob_spec)->te_txtlen = sizeof(gem_file_name);
   form_center(chooser, &cx, &cy, &cw, &ch);
   form_dial(FMD_START, 0, 0, 0, 0, cx, cy, cw, ch);
   objc_draw(chooser, ROOT, MAX_DEPTH, cx, cy, cw, ch);

   /*
   ** the chooser can show up to MAX_NAMES names. If there are fewer than this,
   ** the empty slots are disabled by clearing the TOUCHEXIT flags
   */
   for( i=0; i<MAX_NAMES; i++ ) {
      if( i<nr_names ) {
	 chooser[NAME1+i].ob_flags |= TOUCHEXIT;
      }
      else {
	 chooser[NAME1+i].ob_flags &= ~TOUCHEXIT;
      } /* if */
   } /* for */
   show_names( top );    /* display the font names */

   /** the main loop **/
   
   do {
      button =form_do( chooser, GEMFNAME );
      dprintf(( "\033Hbutton is %x\n", button)); dgetchar();
      if(button&0x8000) {     /* double click */
	 double_click = TRUE;
	 button &= 0x7fff;
      }
      else double_click = FALSE;
      if(button ==DNARR) {
	 if((top+MAX_NAMES)<nr_names) {
	    top++;   /* next name in the list */
	    show_names( top );
	    set_slider_pos(top);
	    objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
	 }
      }
      else if(button ==UPARR) {
	 if(top>0) {
	    top--;
	    show_names( top );
	    set_slider_pos(top);
	    objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
	 }
      }
      else if(button ==SLIDEBAR && nr_names>MAX_NAMES) { /* handle clicks on the slidebar */
	 graf_mkstate(&dum, &mousey, &dum, &dum);     /* where is the mouse - above or below the slider? */
	 objc_offset(chooser, SLIDER, &dum, &slidey);
	 if(mousey<slidey) {                       /* mouse is above the slider */
	    top-=MAX_NAMES;                        /* move up one page of names */
	    if(top<0) top =0;
	 }
	 else {
	    top+=MAX_NAMES;
	    if(top>(nr_names-MAX_NAMES)) top =nr_names-MAX_NAMES;
	 } /* if */
	 show_names( top );
	 set_slider_pos(top);
	 objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
      }
      else if(button ==SLIDER && nr_names>MAX_NAMES) {      /* handle the slider */
	 pos =graf_slidebox(chooser, SLIDEBAR, SLIDER, 1);   /* the position the user wants */
	 chooser[SLIDER].ob_y =pos*(long)(chooser[SLIDEBAR].ob_height-chooser[SLIDER].ob_height)/1000;
	 top =pos*(nr_names-MAX_NAMES)/1000;
	 if(top<0) top =0;
	 if(top>(nr_names-MAX_NAMES)) top =nr_names-MAX_NAMES;
	 show_names( top );
	 objc_draw(chooser, SLIDEBAR, MAX_DEPTH, cx, cy, cw, ch);
      }
      else if(button>=NAME1 && button<=NAME8) {
	 /*** the user has clicked on a font name ***/
	 index = top+button-NAME1;
         dprintf(( "\033Hindex is %d\n", index)); dgetchar();
	 if( iSelected == index ) {    /* the name is already selected */
	    assert( iSelected >=0 );
	    assert( iSelected < nr_names );
	    iSelected = NO_INDEX;      /* deselect it */
	    highlight(button);         /* remove the highlight from the name */
	 }
	 else {
	    /* is the currently selected font name displayed in the box? */
	    if( iSelected!=NO_INDEX
	     && (iSelected+NAME1-top)>=NAME1
	     && (iSelected+NAME1-top)<=NAME8 ) {
	       highlight( iSelected+NAME1-top );        /* remove highlight */
	    } /* if */
	    iSelected = index;    /* set the index for the new selection */
	    highlight(button);         /* and highlight it */
	 } /* if */
	 if(double_click) button =CHOOSEOK;   /* if double clicked on a name, exit immediately */
      } /* if */
      assert( iSelected == NO_INDEX || iSelected >=0 );
      assert( iSelected == NO_INDEX || iSelected < nr_names );
   } while(button!=CHOOSEOK && button!=CHOOSECA);


   /** returned from form, process user actions **/

   dprintf(( "\033HiSelected is %d\n", iSelected)); dgetchar();
   dprintf(( "selected name is %s\n", name_table[iSelected].name ));
   dprintf(( "gem file name is %s\n", 
		     ((TEDINFO *)chooser[GEMFNAME].ob_spec)->te_ptext ));
   dprintf(( "%s format%s\n", 
      chooser[MOT].ob_state&SELECTED ? "motorola" : "intel",
      chooser[WIDONLY].ob_state&SELECTED ? ", width tables only" : "" ));
   dgetchar();

   assert( (chooser[MOT].ob_state & SELECTED) != (chooser[INTEL].ob_state&SELECTED) );
   fMot = (chooser[MOT].ob_state & SELECTED) != 0;
   fWidOnly = (chooser[WIDONLY].ob_state & SELECTED) != 0; 
   chooser[button].ob_state &= ~SELECTED;
   form_dial( FMD_FINISH, 0, 0, 0, 0, cx, cy, cw, ch );
   wind_update( END_UPDATE );
   return button==CHOOSEOK;
} /* select_font() */