Beispiel #1
0
static gboolean display_event_crossing(GtkWidget *widget, GdkEventCrossing *event)
{
  int x = (int) event->x;
  int y = (int) event->y;

  if ( display_current == NULL )
    return TRUE;

  debug(DEBUG_GTK, "CROSSING: type=%d x=%d y=%d focus=%d\n", event->type, x, y, event->focus);
  if ( event->type == GDK_LEAVE_NOTIFY ) {
    display_mouse(-1, -1, event->time);
  }
  else {
    gtk_widget_grab_focus(GTK_WIDGET(display_darea));
    display_mouse(x, y, event->time);
  }

  return TRUE;
}
Beispiel #2
0
static gboolean display_event_motion(GtkWidget *widget, GdkEventMotion *event)
{
  display_t *d = display_current;
  int x = (int) event->x;
  int y = (int) event->y;

  if ( d == NULL )
    return TRUE;

  debug(DEBUG_GTK, "MOTION: type=%d x=%d y=%d\n", event->type, x, y);
  display_mouse(x, y, event->time);

  if ( ! display_input_enabled ) {
    if ( (d->sel_x >= 0) && (d->sel_y >= 0) ) {
      display_selection_update(d, event->x, event->y); 
    }
  }

  return TRUE;
}
Beispiel #3
0
void bootmain()
{
 init_palette();
clear_screen(15);
//boxfill8( (unsigned char *)0xa0000,320,0,    0,0,30,40);
draw_window();
bootinfo *btinfo=(bootinfo *)0xff0;
init_screen(btinfo);

//while(1);


putchar('a',7,30,40);

/*
if(btinfo->xsize=320)
clear_screen(3  );
*/
 puts("1234355656",3,10,70);
 puts("hello world",8,10,100);
 //显示变量,只是实现了%d的处理,后面的以后再完善
 int a=320,b=200;
 char str[20];
 sprintf(str,"xsize=%d,ysize=%d",a,b);
 puts(str,8,10,130);
 char mouse[16*16];

init_gdtidt();
init_mouse(mouse,7);
display_mouse((char*)0xa0000,320,16,16,160,100,mouse,16);
fpt cls=clear_screen;
(*cls)(3);
//display_mouse((char*)0xa0000,320,16,16,160,100,mouse,16);



  while(1);
}
Beispiel #4
0
int do_input_text(char *buf, int size, int width, int (*valid)(char), int (*proc)(int, char *, int *, int *), int mouse_flag, int (*mouse_proc)(int x, int y, char *buf, int *oldlen))
{
   KEYPRESS k;
   int key;
   int askey;
   int ret;
   int x, y, len, cpos;
   int oldlen, c;
   int gap;
   int sel = TRUE;

   x = x_pos;
   y = y_pos;
   len = oldlen = cpos = strlen(buf);

   n_vid();

   do {
      goto1(x, y);

      if ((width > 0) && (len > width)) {
	 gap = len - width;

	 pch('.');
	 pch('.');
	 pch('.');
	 pch(' ');

	 mywrite(buf+gap+4);
      }
      else {
	 gap = 0;

	 mywrite(buf);
      }

      hi_vid();

      for (c=len-gap; c < ((width > 0) ? width : oldlen); c++)
	 pch(' ');

      oldlen = len;

      if (cpos-gap > 0)
	 goto2(x+cpos-gap, y);
      else
	 goto2(x, y);

      show_c();

      if (mouse_flag) {
	 display_mouse();
	 while (m_b)
	    poll_mouse();
	 while (TRUE) {
	    if (input_waiting()) {
	       k = input_char();
	       key = k.key;
	       if ((ascii(key) == CR) && (k.flags & KF_CTRL))
		  key = LF;
	       if (key)
		  break;
	    }
	    poll_mouse();
	    if ((m_b) && (mouse_proc)) {
	       hide_c(); 
	       key = (*mouse_proc)(x, y, buf, &oldlen);
	       len = cpos = strlen(buf);
	       sel = FALSE;
	       show_c();
	       if (key > 0)
		  break;
	    }
	 }
	 hide_mouse();
      }
      else {
	 while (m_b)
	    poll_mouse();

	 while ((!input_waiting()) && (!m_b))
	    poll_mouse();

	 if (m_b) {
	    if (m_b & 2)
	       key = ESC;
	    else
	       key = CR;
	 }
	 else {
	    k = input_char();
	    key = k.key;
	    if ((ascii(key) == CR) && (k.flags & KF_CTRL))
	       key = LF;
	 }
      }

      if ((!proc) || (!(*proc)(key, buf, &len, &cpos))) {

	 if ((key==CTRL_G) || (key==CTRL_C))
	    askey=ESC;
	 else
	    askey=ascii((char)key);

	 if ((askey==ESC) || (askey==CR) || (askey==LF)) {
	    ret = askey;
	    break;
	 }

	 if (key==LEFT_ARROW) {
	    if (cpos > 0)
	       cpos--;
	 }
	 else if (key==RIGHT_ARROW) {
	    if (cpos < len)
	       cpos++;
	 }
	 else if (key==K_HOME) {
	    cpos = 0;
	 }
	 else if (key==K_END) {
	    cpos = MAX(len, 0);
	 } 
	 else {
	    if ((sel) && ((key==K_DELETE) || (askey==BACKSPACE) || 
		  ((*valid)(askey)))) {
	       len = cpos = 0;
	       buf[0] = 0;
	    }

	    if (key==K_DELETE) {
	       if (cpos < len) {
		  for (c=cpos; c<len; c++)
		     buf[c] = buf[c+1];
		  len--;
	       }
	    }
	    else if (askey==BACKSPACE) {
	       if (cpos > 0) {
		  cpos--;
		  for (c=cpos; c<len; c++)
		     buf[c] = buf[c+1];
		  len--;
	       }
	    }
	    else {
	       if ((len<size) && ((*valid)(askey))) {
		  len++;
		  for (c=len; c>cpos; c--)
		     buf[c] = buf[c-1];
		  buf[cpos++]=askey;
	       }
	    }
	 }

	 if (proc)
	    (*proc)(-1, buf, &len, &cpos);
      }

      sel = FALSE;

   } while (TRUE);

   n_vid();
   return ret;
}
Beispiel #5
0
int fsel_mouse(int x, int y, char *s, int *len)
{
   int c, gap;
   int selitem;
   int first = TRUE;
   int changed;
   int d;

   #ifdef TARGET_CURSES
      int count = 0;
   #endif

   if ((m_x < filebox.x) || (m_x >= filebox.x + filebox.w) ||
       (m_y < filebox.y) || (m_y >= filebox.y + filebox.h) || 
       (m_b & 2))
      return ESC;

   if (filebox.count <= 0)
      return 0;

   do {
      delay(10);

      selitem = -1;
      changed = d = FALSE;

      if (mouse_inside_list(&filebox)) {
	 filebox.current = get_mouse_item(&filebox); 
	 if (filebox.current >= filebox.count)
	    filebox.current = filebox.count - 1;
	 else
	    selitem = filebox.current;
	 changed = TRUE;
      }
      else {
	 if ((m_y < filebox.y + filebox.yoff) && (filebox.scroll > 0)) {
	    filebox.scroll--;
	    filebox.current = filebox.scroll;
	    changed = d = TRUE;
	 }
	 else if ((m_y >= filebox.y + filebox.yoff + filebox.height) &&
		  (filebox.scroll < filebox.count - filebox.height)) {
	    filebox.scroll++;
	    filebox.current = filebox.scroll + filebox.height - 1;
	    if (filebox.current >= filebox.count)
	       filebox.current = filebox.count-1;
	    changed = d = TRUE;
	 }
      }

      if (changed) {
	 hide_mouse(); 
	 draw_contents(&filebox);
	 strcpy(s, filebox.data[filebox.current].text);

	 goto1(x, y);
	 hi_vid();

	 if (strlen(s) > 54) {
	    gap = strlen(s) - 54;

	    pch('.');
	    pch('.');
	    pch('.');
	    pch(' ');

	    mywrite(s+gap+4);
	 }
	 else {
	    gap = 0;

	    mywrite(s);
	 }

	 for (c=strlen(s)-gap; c<54; c++)
	    pch(' ');

	 goto2(x+strlen(s+gap), y);

	 *len = strlen(s);
	 display_mouse();
      }

      if (d)
	 delay(20);

      if ((first) && (selitem >= 0))
	 if (!mouse_dclick(FALSE))
	    if (mouse_dclick(TRUE))
	       return CR;

      first = FALSE;

      refresh_screen();

   #ifdef TARGET_CURSES
      if (d) {
	 if (count++ >= 10)
	    m_b = 0;
      }
      else
	 while (m_b)
   #endif
	    poll_mouse(); 

   } while(m_b);

   clear_keybuf();
   return 0;
}
Beispiel #6
0
int do_listbox(LISTBOX *l, int *oklist, int *cancellist, int init_key, int instant_mouse)
{
   int key;
   int *pos;
   int done;
   int ret;
   int c;
   char *b = save_screen(l->x, l->y, l->w, l->h);
   int is_key;

   hide_c();
   draw_listbox(l);

   l->key = init_key;
   l->key2 = -1;

   display_mouse();

   while (m_b) {
      poll_mouse();

      if ((instant_mouse) &&
	  ((m_b & 2) ||
	   (mouse_inside_list(l)) ||
	   ((mouse_inside_parent(l)) &&
	    (get_mouse_item(l->parent) != l->parent->current))))
	 break;
   }

   do {
      if (l->key == -1) {
	 while (!input_waiting()) {
	    poll_mouse();
	    if (m_b)
	       break;
	 }
	 if (input_waiting()) {
	    key = input_char().key;
	    is_key = TRUE;
	 }
	 else {
	    int ox, oy, ob; 
	    int sel_item;
	    int first = TRUE;

	    key = 0;
	    is_key = FALSE;

	    while (m_b) {
	       if ((m_b & 2) && (!(l->flags & LISTBOX_USE_RMB))) {
		  key = ESC;
		  is_key = TRUE;
		  break;
	       }

	       sel_item = -1;
	       if (mouse_inside_list(l)) {
		  l->current = get_mouse_item(l);
		  if (l->current >= l->count)
		     l->current = l->count-1;
		  else
		     sel_item = l->current;
	       }

	       hide_mouse();
	       draw_contents(l);
	       display_mouse();

	       if (first) {
		  if (sel_item >= 0) {
		     if (l->flags & LISTBOX_MOUSE_OK) {
			key = CR;
			is_key = TRUE;
			break;
		     }
		     if (!(l->flags & LISTBOX_MOUSE_OK2)) {
			if (!mouse_dclick(FALSE)) {
			   if (mouse_dclick(TRUE)) {
			      key = CR;
			      is_key = TRUE;
			      break;
			   }
			}
		     }
		  }
		  else if (mouse_outside_list(l)) {
		     if (l->flags & LISTBOX_MOUSE_CANCEL) {
			key = ESC;
			is_key = TRUE;
			break;
		     }
		  }

		  first = FALSE;
	       }

	       if (mouse_inside_parent(l)) {
		  if (l->flags & LISTBOX_MOUSE_CANCEL) {
		     key = ESC;
		     is_key = TRUE;
		     break;
		  }
	       }

	       if (l->flags & LISTBOX_SCROLL) {
		  int changed = FALSE;

		  if ((m_y < l->y + l->yoff) && (l->scroll > 0)) {
		     l->scroll--;
		     l->current = l->scroll;
		     m_y = -1;
		     changed = TRUE;
		  }
		  else if ((m_y >= l->y + l->yoff + l->height) &&
			   (l->scroll < l->count - l->height)) {
		     l->scroll++;
		     l->current = l->scroll + l->height - 1;
		     if (l->current >= l->count)
			l->current = l->count-1;
		     m_y = -1;
		     changed = TRUE;
		  }

		  if (changed) {
		     hide_mouse();
		     draw_contents(l);
		     display_mouse();
		     delay(20);
		  }
	       }

	       do {
		  ox = m_x;
		  oy = m_y;
		  ob = m_b;
		  poll_mouse();
	       } while ((m_x == ox) && (m_y == oy) && 
			(m_b == ob) && (m_b) &&
			(!input_waiting()));

	       if ((!m_b) && (sel_item >= 0) &&
		   (l->flags & LISTBOX_MOUSE_OK2)) {
		  key = CR;
		  is_key = TRUE;
		  break;
	       }
	    }
	 }
      }
      else {
	 key = l->key;
	 l->key = l->key2;
	 l->key2 = -1;
	 is_key = TRUE;
      }

      done = FALSE;

      if (is_key) {
	 pos = oklist;
	 while (*pos) {
	    if ((*pos == key) || (ascii(key)==CR) || (ascii(key)==LF)) {
	       if ((l->current >= 0) && (l->current < l->count)) {
		  hide_mouse();
		  if (l->data[l->current].click_proc)
		     ret = (l->data[l->current].click_proc)
			       (l, l->data+l->current);
		  else
		     ret = l->data[l->current].data;
		  if (ret >= 0) {
		     l->key = key;
		     restore_screen(l->x, l->y, l->w, l->h, b);
		     show_c();
		     return ret;
		  }
		  else {
		     hide_c();
		     display_mouse();
		  }
	       }
	       done = TRUE;
	       break;
	    }
	    pos++;
	 }

	 if (!done) {
	    pos = cancellist;
	    while (*pos) {
	       if ((*pos == key) || (ascii(key)==ESC)) {
		  hide_mouse();
		  l->key = key;
		  restore_screen(l->x, l->y, l->w, l->h, b);
		  show_c();
		  return -1;
	       }
	       pos++;
	    }
	 }

	 if (!done) {
	    if (key==LEFT_ARROW)
	       l->current--;
	    else if (key==UP_ARROW)
	       l->current -= l->width;
	    else if (key==RIGHT_ARROW)
	       l->current++;
	    else if (key==DOWN_ARROW)
	       l->current += l->width;
	    else if (key==PAGE_UP)
	       l->current -= l->width * l->height - 1;
	    else if (key==PAGE_DOWN)
	       l->current += l->width * l->height - 1;
	    else if (key==K_HOME)
	       l->current = 0;
	    else if (key==K_END)
	       l->current = l->count-1;
	    else if (l->process_proc)
	       if ((*l->process_proc)(l, key))
		  goto skip;

	    for (c=0; c<l->count; c++)
	       if (tolower(l->data[c].text[0]) == tolower(ascii(key))) {
		  l->current = c;
		  if (l->flags & LISTBOX_FASTKEY)
		     l->key = oklist[0];
		  break;
	       }

	    skip: 
	    if (l->current < 0) {
	       if (l->flags & LISTBOX_WRAP)
		  l->current = MAX(0, l->count-1);
	       else
		  l->current = 0;
	    }
	    else if (l->current >= l->count) {
	       if (l->flags & LISTBOX_WRAP)
		  l->current = 0;
	       else
		  l->current = MAX(0, l->count-1);
	    }

	    while (l->current < l->scroll)
	       l->scroll -= l->width;
	    while (l->current >= l->scroll+l->width*l->height)
	       l->scroll += l->width;
	 } 
      }

      hide_mouse();
      draw_contents(l);
      display_mouse();

   } while (TRUE);
}