示例#1
0
//! Initializes the CursorManager
CursorManager::CursorManager(void)
{
	fCursorList=new BList(0);

	// Error code for AddCursor
	fTokenizer.ExcludeValue(B_ERROR);

	// Set system cursors to "unassigned"
	ServerCursor *cdefault=new ServerCursor(default_cursor_data);
	AddCursor(cdefault);
	fDefaultCursor=cdefault;
	
	ServerCursor *ctext=new ServerCursor(default_text_data);
	AddCursor(ctext);
	fTextCursor=ctext;

	ServerCursor *cmove=new ServerCursor(default_move_data);
	AddCursor(cmove);
	fMoveCursor=cmove;

	ServerCursor *cdrag=new ServerCursor(default_drag_data);
	AddCursor(cdrag);
	fDragCursor=cdrag;

	ServerCursor *cresize=new ServerCursor(default_resize_data);
	AddCursor(cresize);
	fResizeCursor=cresize;

	ServerCursor *cresizenwse=new ServerCursor(default_resize_nwse_data);
	AddCursor(cresizenwse);
	fNWSECursor=cresizenwse;

	ServerCursor *cresizenesw=new ServerCursor(default_resize_nesw_data);
	AddCursor(cresizenesw);
	fNESWCursor=cresizenesw;

	ServerCursor *cresizens=new ServerCursor(default_resize_ns_data);
	AddCursor(cresizens);
	fNSCursor=cresizens;

	ServerCursor *cresizeew=new ServerCursor(default_resize_ew_data);
	AddCursor(cresizeew);
	fEWCursor=cresizeew;

}
示例#2
0
void LiveServer::BroadcastCursor(const LiveCursor& cursor)
{
	for(PeerList::iterator citer = connected_clients.begin(); citer != connected_clients.end(); ++citer)
	{
		if((*citer)->GetClientID() != cursor.id)
		{
			NetworkMessage* msg = AllocMessage();
			msg->AddByte(PACKET_CURSOR_UPDATE);
			AddCursor(msg, cursor);
			(*citer)->Send(msg);
		}
	}
}
示例#3
0
文件: handler.c 项目: aosm/X11
/*ARGSUSED*/
void 
PopupSearch(Widget w, XEvent * event, String * params, Cardinal * num_params)
{
  ManpageGlobals * man_globals = GetGlobals(w);

  if (man_globals->search_widget) {
    if (!XtIsRealized(man_globals->search_widget)) {
      XtRealizeWidget(man_globals->search_widget);
      AddCursor(man_globals->search_widget, resources.cursors.search_entry);
    }
    Popup(man_globals->search_widget, XtGrabNone);
  }
}
示例#4
0
CGradientCursor* CGradientCtrl::GetGradientCursor(wxPoint point)
{
    CGradientCursor* pRet = NULL;
    ECursorType eType = eCT_Invalid;
    std::vector<CGradientCursor*>* pList = NULL;
    wxRect rect = m_pGradientColorBoard->GetRect();
    if (m_colorIconRect.Contains(point))
    {
        eType = eCT_Color;
        pList = &m_colorCursorList;
    }
    if (m_maskIconRect.Contains(point))
    {
        eType = eCT_Alpha;
        pList = &m_maskCursorList;
    }
    if (eType != eCT_Invalid)
    {
        BEATS_ASSERT(pList != NULL);
        for (auto itr : *pList)
        {
            wxRect iconRect;
            int nPositionX = itr->GetPosPercent() * rect.width - nHalfIconSize + rect.x;
            if (eType == eCT_Color)
            {
                iconRect = wxRect(nPositionX, rect.GetBottom(), CursorIconSize, CursorIconSize);
            }
            else if (eType == eCT_Alpha)
            {
                iconRect = wxRect(nPositionX, rect.GetTop() - CursorIconSize, CursorIconSize, CursorIconSize);
            }

            if (iconRect.Contains(point))
            {
                pRet = itr;
                break;
            }
        }

        if (pRet == NULL)
        {
            float fPos = CalCursorPos(point);
            pRet = new CGradientCursor(fPos, m_pGradientColorBoard->GetColor(rect.width * fPos, eType), eType);
            AddCursor(pRet);
        }
    }
    return pRet;
}
示例#5
0
/*!
	\brief Adds the cursor to the set and replaces any existing entry for the given specifier
	\param which System cursor specifier defined in CursorSet.h
	\param data R5 cursor data pointer
	\return B_BAD_VALUE if data is NULL, otherwise B_OK
	
	When possible, it is better to use the BBitmap version of AddCursor because this 
	function must convert the R5 cursor data into a BBitmap
*/
status_t
CursorSet::AddCursor(BCursorID which, uint8 *data)
{
	// Convert cursor data to a bitmap because all cursors are internally stored
	// as bitmaps
	if (!data)
		return B_BAD_VALUE;

	BBitmap *bmp = _CursorDataToBitmap(data);
	BPoint pt(data[2],data[3]);

	status_t stat = AddCursor(which,bmp,pt);

	delete bmp;
	return stat;
}
示例#6
0
void
MakeTopBox()
{
  Widget form, command, label; /* widgets. */
  Arg arglist[TOPARGS];		/* An argument list */
  Cardinal num_args = 0;	/* The number of arguments. */
  ManpageGlobals * man_globals;
  static char * full_size[] = {
    "topLabel", MANPAGE_BUTTON, NULL
  };
  static char * half_size[] = {
    HELP_BUTTON, QUIT_BUTTON, NULL
  };
  
/* create the top icon. */

  num_args = 0;
  XtSetArg(arglist[num_args], XtNiconPixmap,
	   XCreateBitmapFromData( XtDisplay(initial_widget), 
				 XtScreen(initial_widget)->root,
				 (char *)iconclosed_bits, iconclosed_width,
				 iconclosed_height));
  num_args++;
  XtSetArg(arglist[num_args], XtNtitle, resources.title);
  num_args++;
  XtSetArg(arglist[num_args], XtNiconic, resources.iconic);
  num_args++;
  top = XtCreatePopupShell(TOPBOXNAME, topLevelShellWidgetClass, 
			   initial_widget, arglist, num_args);

  form = XtCreateManagedWidget("form", formWidgetClass, top, 
			       NULL, (Cardinal) 0);

  label = XtCreateManagedWidget("topLabel", labelWidgetClass, form, 
			       NULL, (Cardinal) 0);

  num_args = 0;
  XtSetArg(arglist[num_args], XtNfromVert, label); num_args++;
  command = XtCreateManagedWidget(HELP_BUTTON, commandWidgetClass, form, 
				  arglist, num_args);

  /* use same vertical as help widget. */
  XtSetArg(arglist[num_args], XtNfromHoriz, command); num_args++;
  command = XtCreateManagedWidget(QUIT_BUTTON, commandWidgetClass, form, 
				  arglist, num_args);

  num_args = 0;
  XtSetArg(arglist[num_args], XtNfromVert, command); num_args++;
  command = XtCreateManagedWidget(MANPAGE_BUTTON, commandWidgetClass, form, 
				  arglist, num_args);

  help_widget = NULL;		/* We have not seen the help yet. */

  FormUpWidgets(form, full_size, half_size);

  XtRealizeWidget(top);
				/* add WM_COMMAND property */
  XSetCommand(XtDisplay(top), XtWindow(top), saved_argv, saved_argc);

  man_globals = (ManpageGlobals*) XtMalloc( (Cardinal) sizeof(ManpageGlobals));
  man_globals->label = NULL;
  man_globals->manpagewidgets.directory = NULL;
  man_globals->manpagewidgets.manpage = NULL;
  man_globals->manpagewidgets.box = NULL;
  man_globals->current_directory = 0;
  MakeSearchWidget(man_globals, top);
  MakeSaveWidgets(man_globals, top);

  SaveGlobals( (man_globals->This_Manpage = top), man_globals);
  XtMapWidget(top);
  AddCursor(top, resources.cursors.top);

/*
 * Set up ICCCM delete window.
 */
  wm_delete_window = XInternAtom(XtDisplay(top), "WM_DELETE_WINDOW",
				 False);
  XtOverrideTranslations
      (top, XtParseTranslationTable ("<Message>WM_PROTOCOLS: Quit()"));
  (void) XSetWMProtocols (XtDisplay(top), XtWindow(top),
			  &wm_delete_window, 1);
  

}
示例#7
0
文件: help.c 项目: mit-athena/xmore
Boolean
CreateHelp()
{
  struct stat fileinfo;		/* file information from fstat. */
  FILE * help_file;		/* The stream of the help file. */
  char * help_page;		/* The help text strored in memory. */
  int help_width;		/* The width of the help window. (default). */
  Arg arglist[10];		/* The arglist */
  Cardinal num_args;		/* The number of arguments. */
  Widget pane;			/* The Vpane, that will contain the help info.
				   */
  static XtCallbackRec Callbacks[] = {
    { PopdownHelp, NULL },
    { NULL, NULL },
  };
  
  if (help_widget != NULL)	/* If we already have a help widget. 
				   then do not create one. */
    return(TRUE);

/* Open help_file and read it into memory. */

/*
 * Get file size and allocate a chunk of memory for the file to be 
 * copied into.
 */

  if( (help_file = fopen(help_file_name, "r")) == NULL ) {
    PrintWarning("Could not open help file, NO HELP WILL BE AVALIABLE.");
    return(FALSE);
  }

  if ( stat(help_file_name, &fileinfo) ) {
    PrintWarning("Failure in fstat, NO HELP WILL BE AVALIABLE.");
    return(FALSE);
  }

  /* leave space for the NULL */
  help_page = (char *) malloc(fileinfo.st_size + 1);	

  if (help_page == NULL) {
    PrintWarning(
      "Could not allocate memory for help file, NO HELP WILL BE AVALIABLE.");
    return(FALSE);
  }

/*
 * Copy the file into memory. 
 */
 
  fread(help_page,sizeof(char),fileinfo.st_size,help_file); 
  fclose(help_file);
    
/* put NULL at end of buffer. */

  *(help_page + fileinfo.st_size) = '\0';

/*
 * Help file now loaded in to memory. Create widgets do display it. 
 */

  num_args = 0;
  XtSetArg(arglist[num_args], XtNallowShellResize, TRUE);
  num_args++;

  help_widget = XtCreateApplicationShell("help", applicationShellWidgetClass, 
				   arglist, num_args);

  num_args = 0;
  help_width = DisplayWidth(XtDisplay(help_widget), 
			    DefaultScreen(XtDisplay(help_widget)));
  help_width /= 2;
  XtSetArg(arglist[num_args], XtNwidth, help_width);
  num_args++;

#if XtSpecificationRelease < 4
  pane = XtCreateWidget("Help_VPaned",vPanedWidgetClass,help_widget,
			arglist,num_args);
#else
  pane = XtCreateWidget("Help_Paned",panedWidgetClass,help_widget,
			arglist,num_args);
#endif

  num_args = 0;
  XtSetArg(arglist[num_args], XtNborderWidth, 0);
  num_args++;
  XtSetArg(arglist[num_args], XtNlabel, "Done With Help");
  num_args++;
  XtSetArg(arglist[num_args], XtNcallback, Callbacks);
  num_args++;

  (void) XtCreateManagedWidget("Help_Quit",commandWidgetClass, pane,
			       arglist, num_args);

  num_args = 0;
  XtSetArg(arglist[num_args], XtNborderWidth, 0);
  num_args++;
  XtSetArg(arglist[num_args], XtNstring, help_page);
  num_args++;
#if XtSpecificationRelease < 4
  XtSetArg(arglist[num_args], XtNtextOptions, scrollVertical);
  num_args++;
#else
  XtSetArg(arglist[num_args],XtNscrollVertical,XawtextScrollAlways);
  num_args++;
  XtSetArg(arglist[num_args],XtNscrollHorizontal,XawtextScrollWhenNeeded);
  num_args++;
  XtSetArg(arglist[num_args],XtNuseStringInPlace, TRUE);
  num_args++;
#endif
  /* make the text shown a square box. */
  XtSetArg(arglist[num_args], XtNheight, help_width);
  num_args++;
  

#if XtSpecificationRelease < 4
  (void) XtCreateManagedWidget("Help_Text",asciiStringWidgetClass, pane,
			       arglist, num_args);
#else
  (void) XtCreateManagedWidget("Help_Text",asciiTextWidgetClass, pane,
			       arglist, num_args);
#endif

  XtManageChild(pane);
  XtRealizeWidget(help_widget);
  AddCursor(help_widget,help_cursor);

  return(TRUE);
}