Example #1
0
static int motTextSetClipboardAttrib(Ihandle *ih, const char *value)
{
  if (iupStrEqualNoCase(value, "COPY"))
  {
    char *str = XmTextGetSelection(ih->handle);
    if (!str) return 0;

    XmTextCopy(ih->handle, CurrentTime);

    /* do it also for the X clipboard */
    XStoreBytes(iupmot_display, str, strlen(str)+1);
    XtFree(str);
  }
  else if (iupStrEqualNoCase(value, "CUT"))
  {
    char *str = XmTextGetSelection(ih->handle);
    if (!str) return 0;

    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");

    XmTextCut(ih->handle, CurrentTime);

    /* do it also for the X clipboard */
    XStoreBytes(iupmot_display, str, strlen(str)+1);
    XtFree(str);
    XmTextRemove(ih->handle);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "PASTE"))
  {
    int size;
    char* str = XFetchBytes(iupmot_display, &size);
    if (!str) return 0;

    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");

    XmTextPaste(ih->handle); /* TODO: this could force 2 pastes, check in CDE */

    /* do it also for the X clipboard */
    XmTextRemove(ih->handle);
    XmTextInsert(ih->handle, XmTextGetInsertionPosition(ih->handle), str);
    XFree(str);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "CLEAR"))
  {
    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
    XmTextRemove(ih->handle);
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  return 0;
}
Example #2
0
File: CEdit.C Project: dhaley/dcp
void CEdit::Paste(void)
{
    // Insert data from the clipboard into the text
    if (_xd_textwidget != NULL)
    {
	if (XmIsText(_xd_textwidget))
	    XmTextPaste(_xd_textwidget);
	else if (XmIsTextField(_xd_textwidget))
	    XmTextFieldPaste(_xd_textwidget);
    }
 }
Example #3
0
	int main(int argc, char *argv[])
	{
		int i, n;
		Arg args[10];
		XtAppContext app;
		Widget toplevel, rowcol, textf, text;
		XmString str_months[12];

		setlocale(LC_ALL, "");

		//建立顶级窗口
		toplevel = XtVaAppInitialize(&app, "Edit", NULL, 0,
			&argc, argv, NULL, NULL);

		//建立rowcolumn 布局
		n = 0;
		XtSetArg(args[n], XmNpacking, XmPACK_TIGHT);   n++;
		rowcol = XmCreateRowColumn(toplevel, "rowcol", args, n);
		XtManageChild(rowcol);

		//建立输入条
		n = 0;
		XtSetArg(args[n], XmNvalue, "输入条");	n++;
		textf = XmCreateTextField(rowcol, "textf", args, n);
		XtManageChild(textf);

		//建立文本区
		n = 0;
		XtSetArg(args[n], XmNrows, 10);				n++;
		XtSetArg(args[n], XmNcolumns, 40);			n++;
		XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT);	n++;
		XtSetArg(args[n], XmNwordWrap, True);			n++;
		XtSetArg(args[n], XmNvalue, "输入区域\n请测试");	n++;
		text = XmCreateScrolledText(rowcol, "text", args, n);
		XtManageChild(text);
		
		//显示窗口
		XtRealizeWidget(toplevel);

		//edit
		XmTextSetInsertionPosition(text, 3);
		XmTextInsert(text, 5, "测试插入");
		XmTextSetSelection(text, 5, 8, CurrentTime);
		XmTextCopy(text, CurrentTime);
		XmTextSetInsertionPosition(text, 1);
		XmTextPaste(text);
		

		//进入事件循环
		XtAppMainLoop(app);

	}
Example #4
0
void
editCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	int i;
	char *s;
	long action;
	Time time;
	Widget widget;
	XButtonEvent *event;
	XmPushButtonCallbackStruct *acs;
	XmTextPosition left, right;
	
	action = (long) client_data;
	acs = (XmPushButtonCallbackStruct *) call_data; 
	event = (XButtonEvent *) acs->event;
	time = event->time;
	widget = get_document_text(w, "editCB");
	
	switch (action) {
		case EDIT_CUT:
			XmTextCut(widget, time);
			break;
		case EDIT_COPY:
			XmTextCopy(widget, time);
			break;
		case EDIT_PASTE:
			XmTextPaste(widget);
			break;
		case EDIT_DELETE:
			XmTextRemove(widget);
			break;
		case EDIT_CLEAR:
			if (False == XmTextGetSelectionPosition(widget, 
			    &left, &right)) 
				break; 
			s = calloc(1 + right - left, sizeof(char));
			if (NULL == s) {
				perror("Dtpad (calloc)");
				exit(1);
			}
			for (i = 0; i < right - left; i++) s[i] = ' ';
			s[right - left] = '\0';
			XmTextReplace(widget, left, right, s);
			XtFree(s);
			break;
		default:
			break;
	}
}
Example #5
0
void
editCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	long action;
	Time time;
	Widget widget;
	XButtonEvent *event;
	XmPushButtonCallbackStruct *acs;
	
	action = (long) client_data;
	acs = (XmPushButtonCallbackStruct *) call_data; 
	event = (XButtonEvent *) acs->event;
	time = event->time;
	widget = get_document_text(w, "editCB");
	
	switch (action) {
		case EDIT_CUT:
			XmTextCut(widget, time);
			break;
		case EDIT_COPY:
			XmTextCopy(widget, time);
			break;
		case EDIT_PASTE:
			XmTextPaste(widget);
			break;
		case EDIT_DELETE:
			XmTextRemove(widget);
			break;
		case EDIT_CLEAR:
			edit_clear(widget);
			break;
		default:
			break;
	}
}
Example #6
0
void wxTextEntry::Paste()
{
    XmTextPaste(GetText());
}