Example #1
0
void
overstrikeToggleCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	char *cb;
	Widget doc_w, docw_w, overstrike_lbl_w;
	XmString s;
	XmToggleButtonCallbackStruct *acs;
	
	cb = "overstrikeToggleCB";
	acs = (XmToggleButtonCallbackStruct *)call_data;
	doc_w = get_widget_by_name(w, cb, "documentText");
	docw_w = get_widget_by_name(w, cb, "documentTextWrapped");
	overstrike_lbl_w = get_widget_by_name(w, "overstrikeToggleCB",
	    "overstrikeLabel"); 
	XtCallActionProc(doc_w, "toggle-overstrike", NULL, NULL, 0);
	XtCallActionProc(docw_w, "toggle-overstrike", NULL, NULL, 0);
	
	switch (acs->set) {
		case XmSET:
			s = XmStringCreateLocalized("Overstrike");
			XtVaSetValues(overstrike_lbl_w, 
			    XmNlabelString, s, NULL); 
			break;
		default:
			s = XmStringCreateLocalized("Insert");
			XtVaSetValues(overstrike_lbl_w,
			    XmNlabelString, s, NULL); 
			break;
	}
	
	XmStringFree(s);
}
Example #2
0
void
xlw_popup_menu (Widget widget, XEvent *event)
{
  XlwMenuWidget mw;

  if (!XtIsShell (widget))
    return;

  mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];

  if (event)
    XtCallActionProc ((Widget) mw, "start", event, NULL, 0);
  else
    {
      XEvent dummy;
      XButtonPressedEvent *bd = &dummy.xbutton;

      bd->type = ButtonPress;
      bd->serial = 0;
      bd->send_event = 0;
      bd->display = XtDisplay (widget);
      bd->window = XtWindow (XtParent (widget));
      bd->time = CurrentTime;
      bd->button = 0;
      XQueryPointer (bd->display, bd->window, &bd->root,
		     &bd->subwindow, &bd->x_root, &bd->y_root,
		     &bd->x, &bd->y, &bd->state);

      XtCallActionProc ((Widget) mw, "start", &dummy, NULL, 0);
    }
}
Example #3
0
void DoClearMemo(int which)
{
    Widget edit;

    edit = XtNameToWidget(engineOutputShell, which ? "*form2.text" : "*form.text");
    XtCallActionProc(edit, "select-all", NULL, NULL, 0);
    XtCallActionProc(edit, "kill-selection", NULL, NULL, 0);
}
Example #4
0
void delete_or_controlAct(Widget, XEvent *e, 
			  String *params, Cardinal *num_params)
{
    clear_isearch();
    string input = current_line();
    strip_trailing_newlines(input);
    if (input.empty())
	XtCallActionProc(gdb_w, "gdb-control", e, params, *num_params);
    else
	XtCallActionProc(gdb_w, "delete-next-character", e, params, *num_params);
}
Example #5
0
/*
 * Fake a MotionNotify event to select the new menu item by
 * emulating "<Motion>: highlight() PositionSubmenu()".
 */
static void do_fake_motion(Widget w, XEvent *event, int x, int y)
{
    String empty = "";
    XEvent copy;

    copy = *event;
    copy.type = MotionNotify;
    copy.xmotion.x = x;
    copy.xmotion.y = y;

    XtCallActionProc(w, "highlight", &copy, &empty, 0);
    XtCallActionProc(w, "PositionSubmenu", &copy, &empty, 0);
}
Example #6
0
static void do_menu_select(Widget w, XEvent *event, int keep_menu_up)
{
    String empty = "";

    if (!keep_menu_up) {
        XtCallActionProc(w, "Popdownsubmenus", event, &empty, 0);
        XtCallActionProc(w, "XtMenuPopdown", event, &empty, 0);
    }
    XtCallActionProc(w, "notify", event, &empty, 0);
    if (!keep_menu_up) {
        XtCallActionProc(w, "unhighlight", event, &empty, 0);
    }
}
Example #7
0
static void ParentActivate(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
	if (XmIsManager(w))
	{
		XtCallActionProc(w, "ManagerParentActivate", event, params, *num_params);
	}
	else if (XmIsPrimitive(w))
	{
		XtCallActionProc(w, "PrimitiveParentActivate", event, params, *num_params);
	}
	else
	{
	}
}
Example #8
0
void
SetScroll (Option *opt, float f)
{   // sets top of thumb to given fraction
    static char *params[3] = { "", "Continuous", "Proportional" };
    static XEvent event;
    Widget w = XtParent(opt->handle); // viewport
    Widget v = XtNameToWidget(w, "vertical");
    if(!v) return; // no scroll bar
    XtCallActionProc(v, "StartScroll", &event, params+1, 1);
    XawScrollbarSetThumb(v, f, -1.0);
    XtCallActionProc(v, "NotifyThumb", &event, params, 0);
//    XtCallActionProc(v, "NotifyScroll", &event, params+2, 1);
    XtCallActionProc(v, "EndScroll", &event, params, 0);
}
Example #9
0
void iupdrvActivate(Ihandle* ih)
{
  if (iupStrEqual(ih->iclass->name, "text") || iupStrEqual(ih->iclass->name, "multiline"))
    XmProcessTraversal(ih->handle, XmTRAVERSE_CURRENT);
  else
    XtCallActionProc(ih->handle, "ArmAndActivate", 0, 0, 0 );
}
Example #10
0
void fileRestoreSelect(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
  int i, j;
  FileWindowRec *fw;
  Pixel back, fore;

  j = findWidget(w, &fw);
  if (!fw) {
/*
    error("Internal error:", "widget not found in fileSelect");
*/
    return;
  }
  	for (i=0; i<fw->n_files; i++)
	{
    	XtCallActionProc(fw->files[i]->icon.toggle, "unset", event, NULL, 0);
    	XtVaGetValues(fw->files[i]->icon.toggle, XtNbackground, 
					  							&back, NULL);
    	XtVaSetValues(fw->files[i]->icon.toggle, XtNborder, 
					  							(XtArgVal) back,NULL);
		if (fw->files[i]->selected) 
		{	  
			XtVaGetValues(fw->files[i]->icon.toggle, XtNforeground, 
						  						&fore, NULL);
			XtVaSetValues(fw->files[i]->icon.toggle, XtNborder, 
						  						(XtArgVal) fore, NULL);
    	}		  
	}
	
}
Example #11
0
static void menu_enter_submenu_action(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    /*
     * If there really is a submenu, position_submenu_action()
     * has remembered its Widget.
     */
    if (!active_submenu) {
        return;
    }

    if (w != top_menu) {
#if MENU_DEBUG 
        printf("menu_enter_submenu_action: ignoring event, not top_menu\n");
#endif
        return;
    }
    /*
     * Call this here, instead of in the translation table, since
     * the widget must be adjusted.
     */
    XtCallActionProc(active_keyboard_menu, "unhighlight", event, params, *num_params);

    active_keyboard_menu = active_submenu;

    /*
     * What if the top item in the submenu isn't sensitive...
     * Well, fortunately the current menus don't seem to be like that.
     */
    do_fake_motion(active_keyboard_menu, event, 3, 3);
}
Example #12
0
/*
** Temporary event handlers for keys pressed after the mark or goto-mark
** commands, If the key is valid, grab the key event and call the action
** procedure to mark (or go to) the selection, otherwise, remove the handler
** and give up.
*/
static void processMarkEvent(Widget w, XtPointer clientData, XEvent *event,
    	Boolean *continueDispatch, char *action, int extend)
{
    XKeyEvent *e = (XKeyEvent *)event;
    WindowInfo *window = WidgetToWindow(w);
    Modifiers modifiers;
    KeySym keysym;
    char *params[2], string[2];

    XtTranslateKeycode(TheDisplay, e->keycode, e->state, &modifiers,
    	    &keysym);
    if ((keysym >= 'A' && keysym <= 'Z') || (keysym >= 'a' && keysym <= 'z')) {
    	string[0] = toupper(keysym);
    	string[1] = '\0';
    	params[0] = string;
	params[1] = "extend";
    	XtCallActionProc(window->lastFocus, action, event, params,
		extend ? 2 : 1);
    	*continueDispatch = False;
    }
    XtRemoveEventHandler(w, KeyPressMask, False, markKeyCB, window);
    XtRemoveEventHandler(w, KeyPressMask, False, gotoMarkKeyCB, window);
    XtRemoveEventHandler(w, KeyPressMask, False, gotoMarkExtendKeyCB, window);
    XtRemoveTimeOut(window->markTimeoutID);
}
Example #13
0
void iupdrvActivate(Ihandle* ih)
{
  if (IupClassMatch(ih, "text"))
    XmProcessTraversal(ih->handle, XmTRAVERSE_CURRENT);
  else
    XtCallActionProc(ih->handle, "ArmAndActivate", 0, 0, 0 );
}
Example #14
0
void select_allAct (Widget w, XEvent *e, String *params, Cardinal *num_params)
{
    switch (app_data.select_all_bindings)
    {
    case KDEBindings:
	XtCallActionProc(w, "select-all", e, params, *num_params);
	break;

    case MotifBindings:
	if (w == gdb_w)
	    XtCallActionProc(w, "gdb-beginning-of-line", 
			     e, params, *num_params);
	else
	    XtCallActionProc(w, "beginning-of-line", e, params, *num_params);
	break;
    }
}
Example #15
0
// Veto changes before the current input line
void gdbModifyCB(Widget gdb_w, XtPointer, XtPointer call_data)
{
    if (private_gdb_output)
	return;

    XmTextVerifyCallbackStruct *change = 
	(XmTextVerifyCallbackStruct *)call_data;

    if (do_isearch(gdb_w, change))
	return;

    clear_isearch();

    if (change->startPos < promptPosition)
    {
	// Attempt to change text before prompt
#if 0
	// This only works in LessTif.  
	// With Motif, this causes a core dump on Solaris.  - AZ
	change->doit = false;
#else
	// Make it a no-op
	XmTextPosition lastPos = XmTextGetLastPosition(gdb_w);
	XmTextPosition newPos = lastPos;

	if (change->text->length == 0)
	{
	    // Deletion
	    newPos = promptPosition;
	    if (change->event != 0)
		XtCallActionProc(gdb_w, "beep", change->event, 0, 0);
	}
	else
	{
	    // Some character
	    XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
			    move_to_end_of_line, XtPointer(0));
	}
	change->startPos = change->endPos = 
	    change->newInsert = change->currInsert = newPos;
#endif
	return;
    }

    // Make sure newlines are always inserted at the end of the line
    if (change->startPos == change->endPos &&
	(change->startPos < promptPosition || 
	 (change->text->length == 1 && change->text->ptr[0] == '\n')))
    {
	// Add any text at end of text window
	XmTextPosition lastPos = XmTextGetLastPosition(gdb_w);
	change->newInsert = change->startPos = change->endPos = lastPos;
	
	XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
			move_to_end_of_line, XtPointer(0));
    }
}
Example #16
0
void processAct(Widget w, XEvent *e, String *params, Cardinal *num_params)
{
    if (app_data.source_editing && w == source_view->source())
    {
	// Process event in source window
	string action = "self-insert";   // Default action
	String *action_params      = 0;
	Cardinal num_action_params = 0;
	if (num_params != 0 && *num_params > 0)
	{
	    action = params[0];
	    action_params = params + 1;
	    num_action_params = *num_params - 1;
	}

	XtCallActionProc(w, action.chars(), e, action_params, num_action_params);
	return;
    }

    if (e->type != KeyPress && e->type != KeyRelease)
	return;			// Forward only keyboard events

    if (!XtIsRealized(gdb_w))
	return;			// We don't have a console yet

    if (app_data.console_has_focus == Off)
	return;			// No forwarding

    if (app_data.console_has_focus == Auto && !have_command_window())
	return;			// The console is closed

    static bool running = false;

    if (running)
	return;			// We have already entered this procedure

    running = true;

#if 0
    clear_isearch();		// Why would this be needed?  -AZ
#endif

    // Give focus to GDB console
    XmProcessTraversal(gdb_w, XmTRAVERSE_CURRENT);

    // Forward event to GDB console
    Window old_window = e->xkey.window;
    e->xkey.window = XtWindow(gdb_w);
    XtDispatchEvent(e);
    e->xkey.window = old_window;

    // Return focus to original widget
    XmProcessTraversal(w, XmTRAVERSE_CURRENT);

    running = false;
}
Example #17
0
static void
Down(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    Widget Entry;

    Entry = w;
    while (!XltIsNumEntry(Entry))
	Entry = XtParent(Entry);
    XtCallActionProc(NumEntry_DnArrow(Entry), "ArmAndActivate", event, params, *num_params);
}
Example #18
0
File: vidmode.c Project: aosm/X11
/*ARGSUSED*/
static void
ApplyCallback(Widget w, XtPointer call_data, XtPointer client_data)
{
    hitError = 0;
    XF86VidModeModModeLine(XtDisplay(w), vidtune->screen, &modeline);
    XSync(XtDisplay(w), False);
    if (hitError) {
	if (repeater != NULL) {
	    XtCallActionProc(repeater, "unset", NULL, NULL, 0);
	    XtCallActionProc(repeater, "stop", NULL, NULL, 0);
	    repeater = NULL;
	}
	XBell(XtDisplay(w), 80);
	if (timeout)
	    StopTestCallback(w, NULL, NULL);
	GetModeLine(False);
	SetLabels();
    }
}
Example #19
0
static void
KeyPad(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    Widget Entry;

    Entry = w;
    while (!XltIsNumEntry(Entry))
	Entry = XtParent(Entry);
    event->xkey.state |= Mod2Mask;
    XtCallActionProc(NumEntry_TextField(Entry), "self-insert", event, params, *num_params);
}
Example #20
0
static void DoActionCb(Widget w,XtPointer client_data,XtPointer call_data)
{
    Widget
        menu_w;
#if XmVersion >= 1002
    menu_w=XmGetPostedFromWidget(XtParent(w));
#else
    menu=w;
#endif
    XtCallActionProc(GetShell(menu_w),(char *)client_data,
         ((XmAnyCallbackStruct *)call_data)->event, NULL,0);
}
Example #21
0
/*
** Simulate a button press.  The purpose of this routine is show users what
** is happening when they take an action with a non-obvious side effect,
** such as when a user double clicks on a list item.  The argument is an
** XmPushButton widget to "press"
*/ 
void SimulateButtonPress(Widget widget)
{
    XKeyPressedEvent keyEvent;
    
    memset((char *)&keyEvent, 0, sizeof(XKeyPressedEvent));
    keyEvent.type = KeyPress;
    keyEvent.serial = 1;
    keyEvent.send_event = True;
    keyEvent.display = XtDisplay(widget);
    keyEvent.window = XtWindow(widget);
    XtCallActionProc(widget, "ArmAndActivate", (XEvent *)&keyEvent, NULL, 0);
}
Example #22
0
/*ARGSUSED*/
static void
tic(XtPointer client_data, XtIntervalId *id)
{
    RepeaterWidget rw = (RepeaterWidget)client_data;

    rw->repeater.timer = 0;		/* timer is removed */
    if (rw->repeater.flash) {
	Widget w = (Widget)rw;

	XClearWindow(XtDisplay(w), XtWindow(w));
	XtCallActionProc(w, "reset", NULL, NULL, 0);
	XClearWindow(XtDisplay(w), XtWindow(w));
	XtCallActionProc(w, "set", NULL, NULL, 0);
    }
    DO_CALLBACK(rw);

    rw->repeater.timer = ADD_TIMEOUT(rw, rw->repeater.next_delay);

    if (rw->repeater.decay) {
	rw->repeater.next_delay -= rw->repeater.decay;
	if (rw->repeater.next_delay < rw->repeater.minimum_delay)
	    rw->repeater.next_delay = rw->repeater.minimum_delay;
    }
}
Example #23
0
static int motListSetShowDropdownAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->is_dropdown)
  {
    if (iupStrBoolean(value))
    {
      XButtonEvent ev;
      memset(&ev, 0, sizeof(XButtonEvent));
      ev.type = ButtonPress;
      ev.display = XtDisplay(ih->handle);
      ev.send_event = True;
      ev.root = RootWindow(iupmot_display, iupmot_screen);
      ev.time = clock()*CLOCKS_PER_SEC;
      ev.window = XtWindow(ih->handle);
      ev.state = Button1Mask;
      ev.button = Button1;
      ev.same_screen = True;
      XtCallActionProc(ih->handle, "CBDropDownList", (XEvent*)&ev, 0, 0 ); 
    }
    else
      XtCallActionProc(ih->handle, "CBDisarm", 0, 0, 0 );
  }
  return 0;
}
Example #24
0
static int motActivateMnemonic(Ihandle *dialog, int c)
{
  Ihandle *ih;
  char attrib[19] = "_IUPMOT_MNEMONIC_ ";
  attrib[17] = (char)c;
  ih = (Ihandle*)iupAttribGet(dialog, attrib);
  if (iupObjectCheck(ih))
  {
    Widget w = (Widget)iupAttribGet(ih, attrib);
    if (w)
      XtCallActionProc(w, "ArmAndActivate", 0, 0, 0 );
    else
      iupdrvActivate(ih);
    return IUP_IGNORE;
  }
  return IUP_CONTINUE;
}
Example #25
0
// Use this for push buttons
void gdbApplyCB(Widget w, XtPointer, XtPointer call_data)
{
    if (!gdb->isReadyWithPrompt())
    {
	post_gdb_busy(w);
	return;
    }

    clear_isearch();
    XmPushButtonCallbackStruct *cbs = (XmPushButtonCallbackStruct *)call_data;
    if (cbs->event == 0)
	return;

    Cardinal zero = 0;
    end_of_lineAct(gdb_w, cbs->event, 0, &zero);
    XtCallActionProc(gdb_w, "process-return", cbs->event, 0, zero);
}
Example #26
0
void GotoLineNumber(WindowInfo *window)
{
    char lineNumText[DF_MAX_PROMPT_LENGTH], *params[1];
    int lineNum, column, response;
    
    response = DialogF(DF_PROMPT, window->shell, 2, "Goto Line Number",
            "Goto Line (and/or Column)  Number:", lineNumText, "OK", "Cancel");
    if (response == 2)
    	return;

    if (StringToLineAndCol(lineNumText, &lineNum, &column) == -1) {
    	XBell(TheDisplay, 0);
	return;
    }
    params[0] = lineNumText;
    XtCallActionProc(window->lastFocus, "goto_line_number", NULL, params, 1);
}
Example #27
0
// the bold argument says 0 = normal, 1 = bold typeface
// the colorNr argument says 0 = font-default, 1 = gray
void
ScrollToCursor (Option *opt, int caretPos)
{
    Arg args[10];
    char *s;
    int len;
    GetWidgetText(opt, &s);
    len = strlen(s);
    if(caretPos < 0 || caretPos > len) caretPos = len;
    if(caretPos > len-30) { // scroll to end, which causes no flicker
        static XEvent event;
        XtCallActionProc(opt->handle, "end-of-file", &event, NULL, 0);
        return;
    }
    // the following leads to a very annoying flicker, even when no scrolling is done at all.
    XtSetArg(args[0], XtNinsertPosition, caretPos); // this triggers scrolling in Xaw
    XtSetArg(args[1], XtNdisplayCaret, False);
    XtSetValues(opt->handle, args, 2);
}
Example #28
0
void MarkDialog(WindowInfo *window)
{
    char letterText[DF_MAX_PROMPT_LENGTH], *params[1];
    int response;
    
    response = DialogF(DF_PROMPT, window->shell, 2, "Mark",
            "Enter a single letter label to use for recalling\n"
            "the current selection and cursor position.\n\n"
            "(To skip this dialog, use the accelerator key,\n"
            "followed immediately by a letter key (a-z))", letterText, "OK",
            "Cancel");
    if (response == 2)
    	return;
    if (strlen(letterText) != 1 || !isalpha((unsigned char)letterText[0])) {
    	XBell(TheDisplay, 0);
	return;
    }
    params[0] = letterText;
    XtCallActionProc(window->lastFocus, "mark", NULL, params, 1);
}
Example #29
0
static void menu_exit_submenu_action(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    int i;

    if (w != top_menu) {
#if MENU_DEBUG 
        printf("menu_exit_submenu_action: ignoring event, not top_menu\n");
#endif
        return;
    }

    /*
     * Try to find the parent menu.
     */
    for (i = 0; i < num_submenus; i++) {
        if (submenus[i].widget == active_keyboard_menu) {
            Widget parent_entry;
            XtWidgetGeometry geometry;
            int x, y;

            /*
             * Call this here, instead of in the translation table, since
             * the widget must be adjusted.
             */
            XtCallActionProc(active_keyboard_menu, "unhighlight", event, params, *num_params);

            parent_entry = submenus[i].parent;
            /* get to its SimpleMenu: gleaned from Xaw's SimpleMenu.c */
            active_keyboard_menu = XtParent(parent_entry);
            XtQueryGeometry(parent_entry, NULL, &geometry);
            /* The parent item is probably at this location. */
            x = geometry.x + 1;
            y = geometry.y + 1;

            do_fake_motion(active_keyboard_menu, event, x, y);
            break;
        }
    }
}
static
void PrintOnePageCB(Widget pshell, XtPointer context, XtPointer call_data)
{
    MyPrintCallbackData         *mpcd = (MyPrintCallbackData *)context;
    XawPrintShellCallbackStruct *psp  = (XawPrintShellCallbackStruct *)call_data;
    int                          curr_page;

    curr_page = GetCurrPageNum(pshell);
    Log(("-->  PrintOnePageCB, printing page %d of %d\n", curr_page, mpcd->num_pages));
 
    /* Get ready for next page
     * Scroll widget to display the next page (except for the first page :)
     */
    if (!psp->last_page_in_job && curr_page > 1)
    {
      /* XmText allows two solutions to scroll a page down
       * - Either scroll num_rows_per_page down (this is XmText-specific)
       *   or
       * - Call the "next-page" action procedure (this works for all widgets
       *   which support this action proc)
       */
#define USE_ACTION_TO_SCROLL_DOWN 1
#ifdef USE_ACTION_TO_SCROLL_DOWN
      Log(("Scrolling down one page ...\n"));
      XtCallActionProc(mpcd->printshell_content, "next-page", NULL, NULL, 0);
#else
      Log(("Scrolling down %d rows (=one page) ...\n", mpcd->num_visible_rows));
      XmTextScroll(mpcd->printshell_content, mpcd->num_visible_rows);
#endif /* USE_ACTION_TO_SCROLL_DOWN */
    }
 
    if (curr_page == (int)mpcd->num_pages)
    {
      Log(("Printing last page.\n"));
      psp->last_page_in_job = True;
    }

    Log(("PrintOnePageCB: done\n"));
}