⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fl_x.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 4 页
字号:
    case GR_EVENT_TYPE_CLOSE_REQ:      event = FL_CLOSE;      Fl::handle(event,window);      break;    case GR_EVENT_TYPE_UPDATE:      update = 1;      GR_WINDOW_INFO info;      switch (xevent.update.utype) {      case GR_UPDATE_MAP:	//fix_exposure = 1;	event = FL_SHOW;	GrGetWindowInfo(xid,&info);	//printf("GR_UPDATE_MAP wid: %d\t%d, %d, %d, %d\n", xid,xevent.update.x, xevent.update.y, info.width, info.height); 	//	if(!window->parent())	  window->Fl_Widget::resize(xevent.update.x, xevent.update.y, 				    info.width, info.height);	window->resize_notify(xevent.update.x, xevent.update.y, info.width, info.height);	break;      case GR_UPDATE_SIZE:	GrGetWindowInfo(xid,&info);	//printf("GR_UPDATE_SIZE wid: %d\t%d, %d, %d, %d\n", xid, xevent.update.x, xevent.update.y, info.width, info.height);	//	if(!window->parent())	  window->resize(xevent.update.x, xevent.update.y, info.width, info.height);	window->resize_notify(xevent.update.x, xevent.update.y, info.width, info.height);	//window->resize_notify(info.x, info.y, xevent.update.width, xevent.update.height);	break;      case GR_UPDATE_MOVE:	GrGetWindowInfo(xid,&info);	//printf("GR_UPDATE_MOVE wid: %d\t%d, %d, %d, %d\n", xid, info.x, info.y, xevent.update.width, xevent.update.height); 	/*	if(!window->parent())	  window->Fl_Widget::resize(xevent.update.x, xevent.update.y, 				    info.width, info.height);	window->resize_notify(xevent.update.x, xevent.update.y, info.width, info.height);	*/	//	if(!window->parent())	  window->Fl_Widget::resize(info.x, info.y, 				    xevent.update.width, xevent.update.height);	window->resize_notify(info.x, info.y, xevent.update.width, xevent.update.height);	break;      default:	break;      }      break;    case GR_EVENT_TYPE_EXPOSURE:      Fl_X::i (window)->wait_for_expose = 0;      //if ( !fix_exposure )      	window->damage (FL_DAMAGE_EXPOSE, xevent.exposure.x,		      xevent.exposure.y, xevent.exposure.width,		      xevent.exposure.height);      //fix_exposure = 0;      /*      if (Fl::first_window ()->non_modal ()	  && window != Fl::first_window ())	Fl::first_window ()->show ();*/      break;    case GR_EVENT_TYPE_BUTTON_UP:	//tanghao      if (xevent.button.changebuttons & 0x04) {	button = FL_Button + 0x01;      } else if (xevent.button.changebuttons & 0x02)	button = FL_Button + 0x02;      else	button = FL_Button + 0x03;      Fl::e_keysym = button;	//tanghao have problem +      set_event_xy ();      Fl::e_state &= ~(0x01 << (xevent.button.buttons - 1));	//tanghao have problem      event = FL_RELEASE;      break;    case GR_EVENT_TYPE_BUTTON_DOWN:	//tanghao      if (xevent.button.changebuttons & 0x04) {	button = FL_Button + 0x01;      } else if (xevent.button.changebuttons & 0x02) {	button = FL_Button + 0x02;      } else {	button = FL_Button + 0x03;      }      Fl::e_keysym = button;      set_event_xy ();      checkdouble ();      Fl::e_state |= (0x01 << (xevent.button.buttons - 1));      event = FL_PUSH;      break;    case GR_EVENT_TYPE_MOUSE_POSITION:	//tanghao      fl_window = xevent.mouse.wid;      set_event_xy ();#if CONSOLIDATE_MOTION      send_motion = fl_xmousewin = window;      return 0;#else      event = FL_MOVE;      break;#endif    case GR_EVENT_TYPE_FOCUS_IN:      event = FL_FOCUS;      break;    case GR_EVENT_TYPE_FOCUS_OUT:      event = FL_UNFOCUS;      break;    case GR_EVENT_TYPE_KEY_UP:      {	int keycode = xevent.keystroke.ch;	fl_key_vector[keycode / 8] &= ~(1 << (keycode % 8));	set_event_xy ();	break;      }    case GR_EVENT_TYPE_KEY_DOWN:      {	unsigned short keycode = xevent.keystroke.ch;	static char buffer[21];	int len = 0;	buffer[len++] = keycode;	buffer[len] = 0;	/* Modifiers, passed from Nano-X */	Fl::e_state = 0;	 if ( (keycode == MWKEY_LCTRL) || (keycode == MWKEY_RCTRL) )	   break;	 else if ( (keycode == MWKEY_LALT) || (keycode == MWKEY_RALT ) )	   break;	 else if (keycode == MWKEY_LSHIFT || (keycode == MWKEY_RSHIFT) )	   break;	 	 if (xevent.keystroke.modifiers & MWKMOD_CTRL)	   Fl::e_state |= FL_CTRL;	 if (xevent.keystroke.modifiers & MWKMOD_SHIFT)	   Fl::e_state |= FL_SHIFT;	 if (xevent.keystroke.modifiers & MWKMOD_CAPS)	   Fl::e_state |= FL_CAPS_LOCK;	 if (xevent.keystroke.modifiers & MWKMOD_NUM)	   Fl::e_state |= FL_NUM_LOCK;	 if (xevent.keystroke.modifiers & (MWKMOD_ALT|MWKMOD_META))	   Fl::e_state |= FL_META;	 	 /* This goes through the new keymap_array, and	   handles those keys that are defined.  Otherwise,	   we just drop out and set the keysem to the raw value */	int i = 0;	while (keymap_array[i].value) {	  if (keycode == keymap_array[i].key) {	    Fl::e_keysym = keymap_array[i].value;	    break;	  }	  i++;	}	if (keymap_array[i].value == 0) {	  Fl::e_keysym = (keycode & 0x00FF);	}#ifdef OLDOLDOLD	if (keycode == '\r')	  Fl::e_keysym = (int) 65293;	//tanghao Enter	else if (keycode == '\b')	  Fl::e_keysym = (int) 65288;	//tanghao backspace	else if (keycode == 82)	  Fl::e_keysym = (int) 65362;	//tanghao up	else if (keycode == 84)	  Fl::e_keysym = (int) 65364;	//tanghao down	else if (keycode == 81)	  Fl::e_keysym = (int) 65361;	//tanghao left	else if (keycode == 83)	  Fl::e_keysym = (int) 65363;	//tanghao right	else if (keycode == 227)	  Fl::e_keysym = (int) FL_Control_L;	// left ctrl	else if (keycode == 225)	  Fl::e_keysym = (int) FL_Alt_L;	// left alt	else if (keycode == 233)	  Fl::e_keysym = (int) FL_Shift_L;	// left shift	else	  Fl::e_keysym = (int) (keycode & 0x00FF);	//tanghao#endif	Fl::e_text = buffer;	Fl::e_length = len;	Fl::e_is_click = 0;	event = FL_KEYBOARD;	break;      }    case GR_EVENT_TYPE_MOUSE_ENTER:      set_event_xy ();      //    Fl::e_state = xevent.xcrossing.state << 16;      event = FL_ENTER;      break;    case GR_EVENT_TYPE_MOUSE_EXIT:      set_event_xy ();      //    Fl::e_state = xevent.xcrossing.state << 16;      event = FL_LEAVE;      break;       }  return Fl::handle (event, window);}////////////////////////////////////////////////////////////////voidFl_Window::resize (int X, int Y, int W, int H){  int is_a_resize = (W != w () || H != h ());  int resize_from_program = (this != resize_bug_fix);  if (!resize_from_program)    resize_bug_fix = 0;  if (X != x () || Y != y ())    set_flag (FL_FORCE_POSITION);  else if (!is_a_resize)    return;  if (is_a_resize)     {      Fl_Group::resize (X, Y, W, H);            if (shown ()) 	{	  //redraw ();	  i->wait_for_expose = 1;	}          }   else     {            x (X);      y (Y);        }    if (resize_from_program && shown ())     {      if (is_a_resize) 	{	  GrMoveWindow (i->xid, X + abs (w () - W), Y);	  GrResizeWindow (i->xid, W > 0 ? W : 1, H > 0 ? H : 1);    	}       else 	{	  	  GrMoveWindow (i->xid, X, Y);	  	}    }  }////////////////////////////////////////////////////////////////// A subclass of Fl_Window may call this to associate an X window it// creates with the Fl_Window:int  Fl_X::mw_parent = 1;int  Fl_X::mw_parent_xid = 0;int  Fl_X::mw_parent_top = 0;voidfl_fix_focus ();		// in Fl.cxxFl_X *Fl_X::set_xid (Fl_Window * w, Window xid){  Fl_X *x = new Fl_X;  x->xid = xid;  x->other_xid = 0;  x->setwindow (w);  x->next = Fl_X::first;  x->region = 0;  x->wait_for_expose = 1;  Fl_X::first = x;  if (w->modal ()) {    Fl::modal_ = w;    fl_fix_focus ();  }  return x;}// More commonly a subclass calls this, because it hides the really// ugly parts of X and sets all the stuff for a window that is set// normally.  The global variables like fl_show_iconic are so that// subclasses of *that* class may change the behavior...char fl_show_iconic;		// hack for iconize()int fl_background_pixel = -1;	// hack to speed up bg box drawingint fl_disable_transient_for;	// secret method of removing TRANSIENT_FOR//tanghao static const int childEventMask = ExposureMask;static const int childEventMask = GR_EVENT_MASK_EXPOSURE;	//tanghao#if 0				//tanghaostatic const int XEventMask =  ExposureMask | StructureNotifyMask  | KeyPressMask | KeyReleaseMask | KeymapStateMask | FocusChangeMask  | ButtonPressMask | ButtonReleaseMask  | EnterWindowMask | LeaveWindowMask | PointerMotionMask;#endifstatic const int XEventMask = GR_EVENT_MASK_ALL;	//tanghaovoidFl_X::make_xid (Fl_Window * w, XVisualInfo * visual, Colormap colormap){  Fl_Group::current (0);	// get rid of very common user bug: forgot end()  int X = w->x ();  int Y = w->y ();  int W = w->w ();  if (W <= 0)    W = 1;			// X don't like zero...  int H = w->h ();  if (H <= 0)    H = 1;			// X don't like zero...  // root = either current window id or the MicroWindows root window id.  ulong root;  //if ( !mw_parent && Fl::grab() )  //root = mw_parent_xid;  //else  root = w->parent ()? fl_xid (w->window ()) : GR_ROOT_WINDOW_ID;  GR_WM_PROPERTIES props;  props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE;  GR_CHAR *title = (GR_CHAR *) w->label ();  props.title = title;  props.props = GR_WM_PROPS_APPWINDOW;  if (!mw_parent && !Fl::grab ()) {    // center windows in case window manager does not do anything:    if (!(w->flags () & Fl_Window::FL_FORCE_POSITION)) {      w->x (X = (Fl::w () - W) / 2);      w->y (Y = (Fl::h () - H) / 2);    }    // force the window to be on-screen.  Usually the X window manager    // does this, but a few don't, so we do it here for consistency:    if (w->border ()) {      // ensure border is on screen:      // (assumme extremely minimal dimensions for this border)      const int top = 20;      const int left = 1;      const int right = 1;      const int bottom = 1;      if (X + W + right > Fl::w ())	X = Fl::w () - right - W;      if (X - left < 0)	X = left;      if (Y + H + bottom > Fl::h ())	Y = Fl::h () - bottom - H;      if (Y - top < 0)	Y = top;    }            // now insure contents are on-screen (more important than border):    if (X + W > Fl::w ())      X = Fl::w () - W;    if (X < 0)      X = 0;    if (Y + H > Fl::h ())      Y = Fl::h () - H;    if (Y < 0)      Y = 0;  }  {    GR_WINDOW_ID wid;    wid = GrNewWindow (root, X, Y, W, H, 0, WHITE, BLACK);    //printf("%d = GrNewWindow(%d)\n", wid, root);    if (mw_parent_top == 0) {      mw_parent_xid = wid;      mw_parent_top = 1;    }    if (!mw_parent && Fl::grab ()) {      mw_parent = 1;      props.props = GR_WM_PROPS_NODECORATE;    } else {      mw_parent = 1;    }    props.props |= w->wm_props;    GrSetWMProperties (wid, &props);    Fl_X *x = set_xid (w, wid);    // Start up a MicrowWindow's select events as each window is created.    // This is related with the fl_wait() function above.    if(root == GR_ROOT_WINDOW_ID) {      GrSelectEvents (wid, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_BUTTON_UP |		      GR_EVENT_MASK_MOUSE_POSITION| GR_EVENT_MASK_KEY_DOWN |		      GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMEOUT |		      GR_EVENT_MASK_FOCUS_IN | GR_EVENT_MASK_FOCUS_OUT |		      GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ |		      GR_EVENT_MASK_UPDATE | GR_EVENT_MASK_FDINPUT);    } else {      GrSelectEvents (wid, GR_EVENT_MASK_KEY_DOWN |		      GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMEOUT |		      GR_EVENT_MASK_FOCUS_IN | GR_EVENT_MASK_FOCUS_OUT |		      GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ |		      GR_EVENT_MASK_UPDATE | GR_EVENT_MASK_FDINPUT);          }    w->set_visible ();    w->handle (FL_SHOW);	// get child windows to appear    w->redraw ();    GrMapWindow (x->xid);    fl_window = x->xid;		//tanghao  }#if 0				//tanghao  Fl_X *x = set_xid (w, XCreateWindow (fl_display,				       root,				       X, Y, W, H,				       0,	// borderwidth				       visual->depth,				       InputOutput,				       visual->visual,				       mask, &attr));  w->set_visible ();  w->handle (FL_SHOW);		// get child windows to appear  w->redraw ();  if (!w->parent () && !attr.override_redirect) {    // Communicate all kinds 'o junk to the X Window Manager:    w->label (w->label (), w->iconlabel ());    XChangeProperty (fl_display, x->xid, wm_protocols,		     XA_ATOM, 32, 0, (uchar *) & wm_delete_window, 1);    // send size limits and border:    x->sendxjunk ();    // set the class property, which controls the icon used:    if (w->xclass ()) {      char buffer[1024];      char *p;      const char *q;      // truncate on any punctuation, because they break XResource lookup:      for (p = buffer, q = w->xclass (); isalnum (*q) || (*q & 128);)	*p++ = *q++;      *p++ = 0;      // create the capitalized version:      q = buffer;      *p = toupper (*q++);      if (*p++ == 'X')	*p++ = toupper (*q++);      while ((*p++ = *q++));      XChangeProperty (fl_display, x->xid, XA_WM_CLASS, XA_STRING, 8, 0,		       (unsigned char *) buffer, p - buffer - 1);    }    if (w->non_modal () && x->next && !fl_disable_transient_for) {      // find some other window to be "transient for":      Fl_Window *w = x->next->w;      while (w->parent ())	w = w->window ();      XSetTransientForHint (fl_display, x->xid, fl_xid (w));    }    XWMHints hints;    hints.flags = 0;    if (fl_show_iconic) {      hints.flags = StateHint;      hints.initial_state = IconicState;      fl_show_iconic = 0;    }    if (w->icon ()) {      hints.icon_pixmap = (Pixmap) w->icon ();      hints.flags |= IconPixmapHint;    }    if (hints.flags)      XSetWMHints (fl_display, x->xid, &hints);  }  XMapWindow (fl_display, x->xid);#endif}////////////////////////////////////////////////////////////////// Send X window stuff that can be changed over time:voidFl_X::sendxjunk (){  if (w->parent ())    return;			// it's not a window manager window!  if (!w->size_range_set) {	// default size_range based on resizable():    if (w->resizable ()) {      Fl_Widget *o = w->resizable ();      int minw = o->w ();      if (minw > 100)	minw = 100;      int minh = o->h ();      if (minh > 100)	minh = 100;      w->size_range (w->w () - o->w () + minw, w->h () - o->h () + minh,		     0, 0);    } else {      w->size_range (w->w (), w->h (), w->w (), w->h ());    }    return;			// because this recursively called here  }#if 0				//tanghao  XSizeHints hints;  // memset(&hints, 0, sizeof(hints)); jreiser suggestion to fix purify?  hints.min_width = w->minw;  hints.min_height = w->minh;  hints.max_width = w->maxw;  hints.max_height = w->maxh;  hints.width_inc = w->dw;  hints.height_inc = w->dh;  hints.win_gravity = StaticGravity;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -