static void MakePrompt(Widget centerw, const char *prompt, MakePromptFunc func, const char *def) { static Arg dialogArgs[] = { {XtNlabel, 0}, {XtNvalue, 0}, }; Arg valueArgs[1]; Arg centerArgs[2]; Position source_x, source_y; Position dest_x, dest_y; Dimension center_width, center_height; Dimension prompt_width, prompt_height; Widget valueWidget; CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0); promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass, toplevel, NULL, (Cardinal) 0); dialogArgs[0].value = (XtArgVal)prompt; dialogArgs[1].value = (XtArgVal)def; promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass, promptShell, dialogArgs, XtNumber (dialogArgs)); XawDialogAddButton(promptDialog, "accept", NULL, (XtPointer) 0); XawDialogAddButton(promptDialog, "cancel", NULL, (XtPointer) 0); valueWidget = XtNameToWidget (promptDialog, "value"); if (valueWidget) { XtSetArg (valueArgs[0], (String)XtNresizable, TRUE); XtSetValues (valueWidget, valueArgs, 1); /* * as resizable isn't set until just above, the * default value will be displayed incorrectly. * rectify the situation by resetting the values */ XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs)); } XtSetKeyboardFocus (promptDialog, valueWidget); XtSetKeyboardFocus (toplevel, valueWidget); XtRealizeWidget (promptShell); /* * place the widget in the center of the "parent" */ XtSetArg (centerArgs[0], XtNwidth, ¢er_width); XtSetArg (centerArgs[1], XtNheight, ¢er_height); XtGetValues (centerw, centerArgs, 2); XtSetArg (centerArgs[0], XtNwidth, &prompt_width); XtSetArg (centerArgs[1], XtNheight, &prompt_height); XtGetValues (promptShell, centerArgs, 2); source_x = (center_width - prompt_width) / 2; source_y = (center_height - prompt_height) / 3; XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y); XtSetArg (centerArgs[0], XtNx, dest_x); XtSetArg (centerArgs[1], XtNy, dest_y); XtSetValues (promptShell, centerArgs, 2); XtMapWidget(promptShell); promptfunction = func; }
void XttMotif::open_change_value() { Arg args[1]; int sts; if ( input_open) { XtUnmanageChild( cmd_input); set_prompt( ""); input_open = 0; return; } sts = xnav->check_attr_value(); if ( EVEN(sts)) { message( 'E', XNav::get_message(sts)); return; } if ( command_open) command_open = 0; else XtManageChild( cmd_input); message( ' ', ""); XtSetKeyboardFocus( toplevel, cmd_input); XtSetArg(args[0],XmNvalue, ""); XtSetValues( cmd_input, args, 1); set_prompt( Lng::translate("value >")); input_open = 1; }
void create_dialog(uschar *label, uschar *value) { Arg warg[4]; Dimension x, y, xx, yy; XtTranslations pop_trans; Widget text; /* Get the position of a reference widget so the dialog box can be put near to it. */ get_pos_args[0].value = (XtArgVal)(&x); get_pos_args[1].value = (XtArgVal)(&y); XtGetValues(dialog_ref_widget, get_pos_args, 2); /* When this is not a message_specific thing, the position of the reference widget is relative to the window. Get the position of the top level widget and add to the position. */ if (dialog_ref_widget != menushell) { get_pos_args[0].value = (XtArgVal)(&xx); get_pos_args[1].value = (XtArgVal)(&yy); XtGetValues(toplevel_widget, get_pos_args, 2); x += xx; y += yy; } /* Create a transient shell for the dialog box. */ XtSetArg(warg[0], XtNtransientFor, queue_widget); XtSetArg(warg[1], XtNx, x + 50); XtSetArg(warg[2], XtNy, y + 50); XtSetArg(warg[3], XtNallowShellResize, True); dialog_shell = XtCreatePopupShell("forDialog", transientShellWidgetClass, toplevel_widget, warg, 4); /* Create the dialog box. */ dialog_arg[0].value = (XtArgVal)label; dialog_arg[1].value = (XtArgVal)value; dialog_widget = XtCreateManagedWidget("dialog", dialogWidgetClass, dialog_shell, dialog_arg, XtNumber(dialog_arg)); /* Get the text widget from within the dialog box, give it the keyboard focus, make it wider than the default, and override its translations to make Return call the dialog action function. */ text = XtNameToWidget(dialog_widget, "value"); XawTextSetInsertionPoint(text, Ustrlen(value)); XtSetKeyboardFocus(dialog_widget, text); xs_SetValues(text, 1, "width", 200); pop_trans = XtParseTranslationTable( "<Key>Return: dialogAction()\n"); XtOverrideTranslations(text, pop_trans); /* Pop the thing up. */ XtPopup(dialog_shell, XtGrabExclusive); XFlush(X_display); }
void MakeSearchWidget(ManpageGlobals * man_globals, Widget parent) { Widget dialog, command, text, cancel; Arg arglist[2]; Cardinal num_args = 0; XtSetArg(arglist[0], XtNtransientFor, parent); man_globals->search_widget = XtCreatePopupShell(SEARCHNAME, transientShellWidgetClass, parent, arglist, 1); if (resources.clear_search_string) { XtSetArg(arglist[0], XtNvalue, ""); num_args++; } dialog = XtCreateManagedWidget(DIALOG, dialogWidgetClass, man_globals->search_widget, arglist, num_args); if ((text = XtNameToWidget(dialog, "value")) == (Widget) NULL) PopupWarning(NULL, "Could not find text widget in MakeSearchWidget."); else XtSetKeyboardFocus(dialog, text); XawDialogAddButton(dialog, MANUALSEARCH, NULL, NULL); XawDialogAddButton(dialog, APROPOSSEARCH, NULL, NULL); XawDialogAddButton(dialog, CANCEL, NULL, NULL); /* * This is a bit gross, but it get the cancel button underneath the * others, and forms them up to the right size.. */ if (((command = XtNameToWidget(dialog, MANUALSEARCH)) == (Widget) NULL) || ((cancel = XtNameToWidget(dialog, CANCEL)) == (Widget) NULL)) PopupWarning(NULL, "Could not find manual search widget in MakeSearchWidget."); else { static const char *half_size[] = { MANUALSEARCH, APROPOSSEARCH, NULL }; static const char *full_size[] = { "label", "value", CANCEL, NULL }; num_args = 0; XtSetArg(arglist[num_args], XtNfromVert, command); num_args++; XtSetArg(arglist[num_args], XtNfromHoriz, NULL); num_args++; XtSetValues(cancel, arglist, num_args); FormUpWidgets(dialog, full_size, half_size); } }
/* set the keyboard focus */ void lw_set_keyboard_focus (Widget parent, Widget w) { #if defined (USE_MOTIF) xm_set_keyboard_focus (parent, w); #else XtSetKeyboardFocus (parent, w); #endif }
/* ARGSUSED */ static void CancelAction (Widget widget, XEvent *event, String *params, Cardinal *num_params) { if (promptShell) { XtSetKeyboardFocus(toplevel, (Widget) None); XtDestroyWidget(promptShell); promptShell = (Widget) 0; } }
/************************************************************************ * FUNCTION: PLAYER_Ok * HISTORY: * 01.29.94 ESF Created. * 01.31.94 ESF Delete the strings after registering. * 02.05.94 ESF Remove local registration from here. * 02.05.94 ESF Adding color validity checking. * 03.07.94 ESF Switched to varargs Xt calls. * 03.08.94 ESF Fixed lack of NULL termination in XtVa calls. * 05.04.94 ESF Fixed DistObj changes, added SetNumLivePlayers() * 05.07.94 ESF Fixed to not let too many players register. * 11.16.94 ESF Fixed to not send info to the server re. new player. * 01.15.95 ESF Fixed to not allocate memory for the empty strings. * PURPOSE: * NOTES: ************************************************************************/ void PLAYER_Ok(void) { CString strPlayerName; Int32 iNewPlayer; XColor xColor; char buf[256]; /* Get the name */ XtVaGetValues(wPlayerNameText, XtNstring, &strPlayerName, NULL); /* Don't bother doing anything if something's not filled out */ if (!strlen(strPlayerName)) return; /* See if there are too many players */ if ((iNewPlayer=CLNT_AllocPlayer(CBK_IncomingMessage)) == -1) { (void)UTIL_PopupDialog("Error", "Maximum number of players exceeded!", 1, "Ok", NULL, NULL); return; } /* Get the XColor from the color index */ COLOR_GetColor(COLOR_DieToColor(0), &xColor.red, &xColor.green, &xColor.blue); snprintf(buf, sizeof(buf), "#%02x%02x%02x", xColor.red/256, xColor.green/256, xColor.blue/256); /* Init. the player */ RISK_SetColorCStringOfPlayer(iNewPlayer, buf); RISK_SetSpeciesOfPlayer(iNewPlayer, iCurrentSpecies); RISK_SetNameOfPlayer(iNewPlayer, strPlayerName); /* If the client is human, then the client is this one, otherwise * it's the AI client that registered it. */ if (iCurrentSpecies == SPECIES_HUMAN) RISK_SetClientOfPlayer(iNewPlayer, CLNT_GetThisClientID()); else RISK_SetClientOfPlayer(iNewPlayer, RISK_GetClientOfSpecies(iCurrentSpecies)); /* This player is now finished. Note this */ RISK_SetAllocationStateOfPlayer(iNewPlayer, ALLOC_COMPLETE); /* Make sure the name's erased */ XtVaSetValues(wPlayerNameText, XtNstring, "", NULL); XtPopdown(wAddPlayerShell); fPoppedUp = FALSE; /* Reset keyboard focus */ XtSetKeyboardFocus(wToplevel, wToplevel); }
/* * Function: * AddInsertFileChildren * * Parameters: * form - form widget for the insert dialog widget * ptr - pointer to the initial string for the Text Widget * tw - main text widget * * Description: * Adds all children to the InsertFile dialog widget. */ static void AddInsertFileChildren(Widget form, char *ptr, Widget tw) { Arg args[10]; Cardinal num_args; Widget label, text, cancel, insert; XtTranslations trans; num_args = 0; XtSetArg(args[num_args], XtNlabel, INSERT_FILE); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNresizable, True); num_args++; XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; label = XtCreateManagedWidget(LABEL_NAME, labelWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNfromVert, label); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainRight); num_args++; XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; XtSetArg(args[num_args], XtNresizable, True); num_args++; XtSetArg(args[num_args], XtNstring, ptr); num_args++; text = XtCreateManagedWidget(TEXT_NAME, asciiTextWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNlabel, "Insert File"); num_args++; XtSetArg(args[num_args], XtNfromVert, text); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; insert = XtCreateManagedWidget("insert", commandWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++; XtSetArg(args[num_args], XtNfromVert, text); num_args++; XtSetArg(args[num_args], XtNfromHoriz, insert); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form, args, num_args); XtAddCallback(cancel, XtNcallback, PopdownFileInsert, (XtPointer)tw); XtAddCallback(insert, XtNcallback, DoInsert, (XtPointer)tw); XtSetKeyboardFocus(form, text); /* * Bind <CR> to insert file */ trans = XtParseTranslationTable("<Key>Return:InsertFileAction()"); XtOverrideTranslations(text, trans); }
static void combo_text_edit(Widget w, XtPointer p, XEvent *event, Boolean *n) { MwComboWidget cw = (MwComboWidget)XtParent(w); char *old = MwTextFieldGetString(w); XtAddGrab(w, True, False); if (cw->combo.topLevel != None) { XtSetKeyboardFocus(cw->combo.topLevel, w); } XtVaSetValues(w, XtNdisplayCaret, True, (char *)0); combo_status = WAITING; while (combo_status == WAITING) { int count, bufsiz = 10; XEvent event; XtAppNextEvent(XtWidgetToApplicationContext(w), &event); if (event.type == KeyPress) { char buf[12]; KeySym keysym; XKeyEvent kevent = event.xkey; count = XLookupString(&kevent, buf, bufsiz, &keysym, NULL); if (keysym == XK_Escape) combo_status = ABORT; else if (keysym == XK_Return) combo_status = DONE; else XtDispatchEvent(&event); } else { XtDispatchEvent(&event); } } XtVaSetValues(w, XtNdisplayCaret, False, (char *)0); XtRemoveGrab(w); if (cw->combo.topLevel) { XtSetKeyboardFocus(cw->combo.topLevel, None); } if (combo_status == ABORT) MwTextFieldSetString(w, old); XtCallCallbackList((Widget)cw, cw->combo.text_callbacks, (XtPointer)MwTextFieldGetString(w)); }
/**************************************************************** ... *****************************************************************/ Widget input_dialog_create(Widget parent, const char *dialogname, const char *text, const char *postinputtest, XtCallbackProc ok_callback, XtPointer ok_cli_data, XtCallbackProc cancel_callback, XtPointer cancel_cli_data) { Widget shell, form, label, input, ok, cancel; XtSetSensitive(parent, FALSE); I_T(shell=XtCreatePopupShell(dialogname, transientShellWidgetClass, parent, NULL, 0)); form=XtVaCreateManagedWidget("iform", formWidgetClass, shell, NULL); /* Caller should i18n the text passed in as desired */ label=XtVaCreateManagedWidget("ilabel", labelWidgetClass, form, XtNlabel, (XtArgVal)text, NULL); input=XtVaCreateManagedWidget("iinput", asciiTextWidgetClass, form, XtNfromVert, (XtArgVal)label, XtNeditType, XawtextEdit, XtNstring, postinputtest, NULL); ok=XtVaCreateManagedWidget("iokcommand", commandWidgetClass, form, XtNlabel, (XtArgVal)_("Ok"), XtNfromVert, input, NULL); cancel=XtVaCreateManagedWidget("icancelcommand", commandWidgetClass, form, XtNlabel, (XtArgVal)_("Cancel"), XtNfromVert, input, XtNfromHoriz, ok, NULL); xaw_set_relative_position(parent, shell, 10, 10); XtPopup(shell, XtGrabNone); XtAddCallback(ok, XtNcallback, ok_callback, ok_cli_data); XtAddCallback(cancel, XtNcallback, cancel_callback, cancel_cli_data); XtSetKeyboardFocus(parent, input); return shell; }
static void Realize(Widget w, XtValueMask *valueMask, XSetWindowAttributes *attrs) { *valueMask |= CWBackingStore; attrs->backing_store = Always; XtCreateWindow(w, InputOutput, (Visual *)0, *valueMask, attrs); XtSetKeyboardFocus(w->core.parent, w); if ((modmap = XGetModifierMapping(XtDisplay(w)))) keypermod = modmap->max_keypermod; Resize(w); }
// // Show the text input widget. // int WFoeMotif::get_textinput( const char *msg, int (*function)(WFoe *, char *)) { /* Print the text */ message( msg); /* View the input widget */ XtManageChild( widgets.textinput); XtSetKeyboardFocus( parent_wid, widgets.textinput); /* Insert the function in foe */ textinput_func = function; return FOE__SUCCESS; }
/************************************************************************ * FUNCTION: PLAYER_PopupDialog * HISTORY: * 01.29.95 ESF Created. * 02.26.95 ESF Fixed to generate brighter random colors. * 04.30.95 ESF Fixed to generate even brighter random colors. * 05.06.95 ESF Fixed a bug whereas the wrong species was highlighted. * 15.01.00 MSH Fixed to update color indicator to initial color. * PURPOSE: * NOTES: called from "Register players" ************************************************************************/ void PLAYER_PopupDialog(void) { Int32 x, y; /* Center the new shell */ UTIL_CenterShell(wAddPlayerShell, wToplevel, &x, &y); XtVaSetValues(wAddPlayerShell, XtNallowShellResize, False, XtNx, x, XtNy, y, XtNborderWidth, 1, XtNtitle, "Add Player", NULL); /* TBD: Could make sure here that COLOR_DieToColor(0) had a * reasonable color for the new player, i.e. unique, nice... * for now pick a random color...but not too dim!! */ PLAYER_InitColor(); /* Update the color indicator */ XtVaSetValues(wPlayerColorDisplay, XtNbackground, COLOR_QueryColor(COLOR_DieToColor(0)), NULL); /* Do the species stuff */ PLAYER_RenderSpecies(); PLAYER_SetSpecies(iCurrentSpecies); XawListHighlight(wPlayerSpeciesListbox, PLAYER_SpeciesToSlot(iCurrentSpecies)); /* Pop the dialog up, set the keyboard focus */ XtPopup(wAddPlayerShell, XtGrabExclusive); fPoppedUp = TRUE; XtSetKeyboardFocus(wToplevel, wPlayerNameText); XtSetKeyboardFocus(wAddPlayerShell, wPlayerNameText); }
/* ARGSUSED */ static void CancelAction (Widget widget, XEvent *event, String *params, Cardinal *num_params) { widget = widget; /* unused; suppress compiler warning */ event = event; params = params; num_params = num_params; if (promptShell) { XtSetKeyboardFocus(toplevel, (Widget) None); XtDestroyWidget(promptShell); promptShell = (Widget) 0; } }
static void XawVendorShellChangeManaged(Widget wid) { ShellWidget w = (ShellWidget) wid; Widget* childP; int i; (*SuperClass->composite_class.change_managed)(wid); for (i = w->composite.num_children, childP = w->composite.children; i; i--, childP++) { if (XtIsManaged(*childP)) { XtSetKeyboardFocus(wid, *childP); break; } } }
void SetFocus (Widget w, XtPointer data, XEvent *event, Boolean *b) { Arg args[2]; char *s; int j; UnCaret(); XtSetArg(args[0], XtNstring, &s); XtGetValues(w, args, 1); j = 1; XtSetArg(args[0], XtNdisplayCaret, True); if(!strchr(s, '\n') && strlen(s) < 80) XtSetArg(args[1], XtNinsertPosition, strlen(s)), j++; XtSetValues(w, args, j); XtSetKeyboardFocus((Widget) data, w); previous = w; }
/* * Function: * CreateDialogValueWidget * * Parameters: * w - dialog widget * * Description: * Creates the dialog widgets value widget. * * Note * Must be called only when w->dialog.value is non-nil */ static void CreateDialogValueWidget(Widget w) { DialogWidget dw = (DialogWidget)w; Arg arglist[10]; Cardinal num_args = 0; XtSetArg(arglist[num_args], XtNstring, dw->dialog.value); num_args++; XtSetArg(arglist[num_args], XtNresizable, True); num_args++; XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); num_args++; XtSetArg(arglist[num_args], XtNfromVert, dw->dialog.labelW); num_args++; XtSetArg(arglist[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(arglist[num_args], XtNright, XtChainRight); num_args++; dw->dialog.valueW = XtCreateWidget("value", asciiTextWidgetClass, w, arglist, num_args); /* if the value widget is being added after buttons, * then the buttons need new layout constraints */ if (dw->composite.num_children > 1) { WidgetList children = dw->composite.children; Widget *childP; for (childP = children + dw->composite.num_children - 1; childP >= children; childP-- ) { if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW) continue; if (XtIsManaged(*childP) && XtIsSubclass(*childP, commandWidgetClass)) { ((DialogConstraints)(*childP)->core.constraints)-> form.vert_base = dw->dialog.valueW; } } } XtManageChild(dw->dialog.valueW); /* * Value widget gets the keyboard focus */ XtSetKeyboardFocus(w, dw->dialog.valueW); dw->dialog.value = MAGIC_VALUE; }
/************************************************************************ * FUNCTION: PLAYER_Cancel * HISTORY: * 01.29.95 ESF Created. * 02.12.95 ESF Finished. * PURPOSE: * NOTES: ************************************************************************/ void PLAYER_Cancel(void) { CString strName; /* Make sure the player name widget * is empty, popup warning if not. */ XtVaGetValues(wPlayerNameText, XtNstring, &strName, NULL); if (strlen(strName)) if (UTIL_PopupDialog("Warning", "Discard current registration data?", 2, "Yes", "No", NULL) == QUERY_NO) return; XtPopdown(wAddPlayerShell); /* Reset keyboard focus */ XtSetKeyboardFocus(wToplevel, wToplevel); }
/**************************************************************** popup the dialog 5% inside the main-window *****************************************************************/ void popup_races_dialog(struct player *pplayer) { Position x, y; Dimension width, height; XtSetSensitive(main_form, FALSE); if (!races_dialog_shell) { create_races_dialog(pplayer); } XtVaGetValues(toplevel, XtNwidth, &width, XtNheight, &height, NULL); XtTranslateCoords(toplevel, (Position) width/20, (Position) height/20, &x, &y); XtVaSetValues(races_dialog_shell, XtNx, x, XtNy, y, NULL); XtPopup(races_dialog_shell, XtGrabNone); XtSetKeyboardFocus(toplevel, races_dialog_shell); }
void XttMotif::activate_command( Widget w, Xtt *xtt, XmAnyCallbackStruct *data) { Arg args[1]; if ( xtt->command_open) { XtUnmanageChild( ((XttMotif *)xtt)->cmd_input); xtt->set_prompt( ""); xtt->command_open = 0; return; } if ( xtt->input_open) xtt->input_open = 0; else XtManageChild( ((XttMotif *)xtt)->cmd_input); xtt->message( ' ', ""); XtSetKeyboardFocus( ((XttMotif *)xtt)->toplevel, ((XttMotif *)xtt)->cmd_input); XtSetArg(args[0],XmNvalue, ""); XtSetValues( ((XttMotif *)xtt)->cmd_input, args, 1); xtt->set_prompt( "xtt >"); xtt->command_open = 1; }
void ChooseWindowStructureNotifyXtHandler(Widget w, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch) { if (event->type == MapNotify) { /* * Set the input focus to the choose window and direct all keyboard * events to the list widget. This way, the user can make selections * using the keyboard. */ XtSetKeyboardFocus (chooseSessionPopup, chooseSessionListWidget); XSetInputFocus (XtDisplay (topLevel), XtWindow (chooseSessionPopup), RevertToPointerRoot, CurrentTime); XSync (XtDisplay (topLevel), 0); XtRemoveEventHandler (chooseSessionPopup, StructureNotifyMask, False, ChooseWindowStructureNotifyXtHandler, NULL); } }
void BoardFocus () { XtSetKeyboardFocus(shellWidget, formWidget); }
void awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht) { Widget parent; Dimension ww, wh; Position wx, wy; Boolean move = False; Boolean resize = False; Boolean mapped_when_managed = False; Boolean need_to_unmanage = True; Widget saved_focus_widget = NULL; if (w == NULL) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNU_ThrowNullPointerException(env,"NullPointerException"); return; } parent = XtParent(w); /* Aim: hack to prevent direct children of scrollpane from * being unmanaged during a reshape operation (which results * in too many expose events). */ if (parent != NULL && XtParent(parent) != NULL && XtIsSubclass(XtParent(parent), xmScrolledWindowWidgetClass)) { need_to_unmanage = False; } XtVaGetValues(w, XmNwidth, &ww, XmNheight, &wh, XmNx, &wx, XmNy, &wy, NULL); if (x != wx || y != wy) { move = True; } if (wd != ww || ht != wh) { resize = True; } if (!move && !resize) { return; } if (need_to_unmanage) { if (!resize) { mapped_when_managed = w->core.mapped_when_managed; w->core.mapped_when_managed = False; } saved_focus_widget = get_shell_focused_widget(w); XtUnmanageChild(w); } /* GES: AVH's hack: * Motif ignores attempts to move a toplevel window to 0,0. * Instead we set the position to 1,1. The expected value is * returned by Frame.getBounds() since it uses the internally * held rectangle rather than querying the peer. * N.B. [pauly, 9/97] This is only required for wm shells * under the Motif Window Manager (MWM), not for any others. * Note. Utilizes C short-circuiting if w is not a wm shell. */ if ((x == 0) && (y == 0) && (XtIsSubclass(w, wmShellWidgetClass)) && (XmIsMotifWMRunning(w))) { XtVaSetValues(w, XmNx, 1, XmNy, 1, NULL); } if (move && !resize) { XtVaSetValues(w, XmNx, x, XmNy, y, NULL); } else if (resize && !move) { XtVaSetValues(w, XmNwidth, (wd > 0) ? wd : 1, XmNheight, (ht > 0) ? ht : 1, NULL); } else { XtVaSetValues(w, XmNx, x, XmNy, y, XmNwidth, (wd > 0) ? wd : 1, XmNheight, (ht > 0) ? ht : 1, NULL); } if (need_to_unmanage) { XtManageChild(w); if (!resize) { w->core.mapped_when_managed = mapped_when_managed; } if (saved_focus_widget != NULL) { Boolean result = XmProcessTraversal(saved_focus_widget, XmTRAVERSE_CURRENT); if (!result) { Widget shell = saved_focus_widget; while(shell != NULL && !XtIsShell(shell)) { shell = XtParent(shell); } XtSetKeyboardFocus(shell, saved_focus_widget); } } } }
/**************************************************************** ... *****************************************************************/ void create_races_dialog(struct player *pplayer) { int per_row = 5; int i, j, len, maxracelen, index, nat_count; char maxracename[MAX_LEN_NAME]; char namebuf[64]; int space; XtWidgetGeometry geom; races_player = pplayer; maxracelen = 0; nations_iterate(pnation) { if (is_nation_playable(pnation)) { len = strlen(nation_adjective_translation(pnation)); maxracelen = MAX(maxracelen, len); } } nations_iterate_end; maxracelen = MIN(maxracelen, MAX_LEN_NAME-1); fc_snprintf(maxracename, sizeof(maxracename), "%*s", maxracelen+2, "W"); races_dialog_shell = I_T(XtCreatePopupShell("racespopup", transientShellWidgetClass, toplevel, NULL, 0)); races_form = XtVaCreateManagedWidget("racesform", formWidgetClass, races_dialog_shell, NULL); races_label = I_L(XtVaCreateManagedWidget("raceslabel", labelWidgetClass, races_form, NULL)); races_toggles_viewport = XtVaCreateManagedWidget("racestogglesviewport", viewportWidgetClass, races_form, XtNfromVert, races_label, NULL); races_toggles_form = XtVaCreateManagedWidget("racestogglesform", formWidgetClass, races_toggles_viewport, NULL); free(races_toggles); races_toggles = fc_calloc(nation_count(), sizeof(Widget)); free(races_toggles_to_nations); races_toggles_to_nations = fc_calloc(nation_count(), sizeof(struct nation_type *)); i = 0; j = 0; index = 0; nations_iterate(pnation) { if (!is_nation_playable(pnation)) { continue; } if (j == 0) { index = i * per_row; fc_snprintf(namebuf, sizeof(namebuf), "racestoggle%d", index); if (i == 0) { races_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_toggles_form, XtNlabel, maxracename, NULL); } else { races_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_toggles_form, XtNradioGroup, races_toggles[index - 1], XtNfromVert, races_toggles[index - per_row], XtNlabel, maxracename, NULL); } } else { index = i * per_row + j; fc_snprintf(namebuf, sizeof(namebuf), "racestoggle%d", index); if (i == 0) { races_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_toggles_form, XtNradioGroup, races_toggles[index - 1], XtNfromHoriz, races_toggles[index - 1], XtNlabel, maxracename, NULL); } else { races_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_toggles_form, XtNradioGroup, races_toggles[index - 1], XtNfromVert, races_toggles[index - per_row], XtNfromHoriz, races_toggles[index - 1], XtNlabel, maxracename, NULL); } } races_toggles_to_nations[index] = pnation; j++; if (j >= per_row) { j = 0; i++; } } nations_iterate_end; nat_count = index + 1; races_leader_form = XtVaCreateManagedWidget("racesleaderform", formWidgetClass, races_form, XtNfromVert, races_toggles_viewport, /* XtNfromHoriz, races_toggles_viewport,*/ NULL); XtVaGetValues(races_leader_form, XtNdefaultDistance, &space, NULL); XtQueryGeometry(races_toggles[0], NULL, &geom); races_leader = XtVaCreateManagedWidget("racesleader", asciiTextWidgetClass, races_leader_form, XtNeditType, XawtextEdit, XtNwidth, space + 2*(geom.width + geom.border_width), XtNstring, "", NULL); races_leader_pick_popupmenu = 0; races_leader_pick_menubutton = I_L(XtVaCreateManagedWidget("racesleaderpickmenubutton", menuButtonWidgetClass, races_leader_form, /* XtNfromVert, races_leader,*/ XtNfromHoriz, races_leader, NULL)); races_sex_label = I_L(XtVaCreateManagedWidget("racessexlabel", labelWidgetClass, races_form, XtNfromVert, races_leader_form, NULL)); races_sex_form = XtVaCreateManagedWidget("racessexform", formWidgetClass, races_form, XtNfromVert, races_sex_label, NULL); races_sex_toggles[0] = I_L(XtVaCreateManagedWidget("racessextoggle0", toggleWidgetClass, races_sex_form, NULL)); races_sex_toggles[1] = I_L(XtVaCreateManagedWidget("racessextoggle1", toggleWidgetClass, races_sex_form, XtNfromHoriz, (XtArgVal)races_sex_toggles[0], XtNradioGroup, races_sex_toggles[0], NULL)); /* find out styles that can be used at the game beginning */ /* Limit of 64 city_styles should be deleted. -ev */ for (i = 0, b_s_num = 0; i < game.control.styles_count && i < 64; i++) { if (!city_style_has_requirements(&city_styles[i])) { city_style_idx[b_s_num] = i; city_style_ridx[i] = b_s_num; b_s_num++; } } races_style_label = I_L(XtVaCreateManagedWidget("racesstylelabel", labelWidgetClass, races_form, XtNfromVert, races_sex_form, /* XtNfromHoriz, races_toggles_viewport,*/ NULL)); races_style_form = XtVaCreateManagedWidget("racesstyleform", formWidgetClass, races_form, XtNfromVert, races_style_label, /* XtNfromHoriz, races_toggles_viewport,*/ NULL); free(races_style_toggles); races_style_toggles = fc_calloc(b_s_num,sizeof(Widget)); for( i = 0; i < ((b_s_num-1)/per_row)+1; i++) { index = i * per_row; fc_snprintf(namebuf, sizeof(namebuf), "racesstyle%d", index); if( i == 0 ) { races_style_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_style_form, XtNlabel, maxracename, NULL); } else { races_style_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_style_form, XtNradioGroup, races_style_toggles[index-1], XtNfromVert, races_style_toggles[index-per_row], XtNlabel, maxracename, NULL); } for( j = 1; j < per_row; j++) { index = i * per_row + j; if( index >= b_s_num ) break; fc_snprintf(namebuf, sizeof(namebuf), "racesstyle%d", index); if( i == 0 ) { races_style_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_style_form, XtNradioGroup, races_style_toggles[index-1], XtNfromHoriz, races_style_toggles[index-1], XtNlabel, maxracename, NULL); } else { races_style_toggles[index] = XtVaCreateManagedWidget(namebuf, toggleWidgetClass, races_style_form, XtNradioGroup, races_style_toggles[index-1], XtNfromVert, races_style_toggles[index-per_row], XtNfromHoriz, races_style_toggles[index-1], XtNlabel, maxracename, NULL); } } } races_action_form = XtVaCreateManagedWidget("racesactionform", formWidgetClass, races_form, XtNfromVert, races_style_form, NULL); races_ok_command = I_L(XtVaCreateManagedWidget("racesokcommand", commandWidgetClass, races_action_form, NULL)); races_random_command = I_L(XtVaCreateManagedWidget("racesdisconnectcommand", commandWidgetClass, races_action_form, XtNfromHoriz, races_ok_command, NULL)); races_quit_command = I_L(XtVaCreateManagedWidget("racesquitcommand", commandWidgetClass, races_action_form, XtNfromHoriz, races_random_command, NULL)); XtAddCallback(races_random_command, XtNcallback, races_random_command_callback, NULL); XtAddCallback(races_quit_command, XtNcallback, races_quit_command_callback, NULL); for (i = 0; i < nation_count(); i++) { if (races_toggles[i]) { XtAddCallback(races_toggles[i], XtNcallback, races_toggles_callback, INT_TO_XTPOINTER(i)); } } XtAddCallback(races_ok_command, XtNcallback, races_ok_command_callback, NULL); XtSetKeyboardFocus(races_form, races_leader); XtRealizeWidget(races_dialog_shell); /* for(i=0; i<game.control.playable_nation_count; i++) { races_toggles_to_nations[i] = i; } */ qsort(races_toggles_to_nations, nat_count, sizeof(struct nation_type *), races_indirect_compare); /* Build nation_to_race_toggle */ free(nation_idx_to_race_toggle); nation_idx_to_race_toggle = fc_calloc(nation_count(), sizeof(int)); for (i = 0; i < nation_count(); i++) { nation_idx_to_race_toggle[i] = -1; } for (i = 0; i < nation_count(); i++) { if (races_toggles_to_nations[i]) { nation_idx_to_race_toggle[nation_index(races_toggles_to_nations[i])] = i; } } for (i = 0; i < nation_count(); i++) { if (races_toggles[i]) { XtVaSetValues(races_toggles[i], XtNlabel, (XtArgVal)nation_adjective_translation(races_toggles_to_nations[i]), NULL); } } for(i=0; i<b_s_num; i++) { XtVaSetValues(races_style_toggles[i], XtNlabel, (XtArgVal)city_style_name_translation(city_style_idx[i]), NULL); } select_random_race(); }
void popup_spell_check_panel(char **list, int nitems) { static Boolean actions_added = False; Widget form, dismiss_button, below, label; int x_val, y_val; /* if panel already exists, just replace the list of words */ if (spell_check_panel != None) { XawListChange(word_list, list, nitems, 0, False); } else { /* must create it */ get_pointer_root_xy(&x_val, &y_val); FirstArg(XtNx, (Position) x_val); NextArg(XtNy, (Position) y_val); NextArg(XtNcolormap, tool_cm); NextArg(XtNtitle, "Xfig: Misspelled words"); spell_check_panel = XtCreatePopupShell("spell_check_panel", transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(spell_check_panel, XtParseTranslationTable(spell_panel_translations)); if (!actions_added) { XtAppAddActions(tool_app, spell_actions, XtNumber(spell_actions)); actions_added = True; } form = XtCreateManagedWidget("form", formWidgetClass, spell_check_panel, NULL, ZERO); /* make a label to report either "No misspelled words" or "Misspelled words:" */ FirstArg(XtNlabel, "Spell checker"); NextArg(XtNjustify, XtJustifyLeft); NextArg(XtNwidth, 375); NextArg(XtNheight, 20); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); spell_msg_win = XtCreateManagedWidget("spell_msg_win", labelWidgetClass, form, Args, ArgCount); /* labels for list and correct word entry */ FirstArg(XtNlabel, "Misspelled words "); NextArg(XtNfromVert, spell_msg_win); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); label = XtCreateManagedWidget("misspelled_label", labelWidgetClass, form, Args, ArgCount); below = label; FirstArg(XtNlabel, "Correction"); NextArg(XtNfromVert, spell_msg_win); NextArg(XtNfromHoriz, label); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); label = XtCreateManagedWidget("correction_label", labelWidgetClass, form, Args, ArgCount); /* make a viewport to hold the list widget containing the misspelled words */ FirstArg(XtNallowVert, True); NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 1); NextArg(XtNwidth, 150); NextArg(XtNheight, 200); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); spell_viewport = XtCreateManagedWidget("spellvport", viewportWidgetClass, form, Args, ArgCount); /* now make the list widget */ FirstArg(XtNlist, list); NextArg(XtNnumberStrings, nitems); NextArg(XtNforceColumns, True); /* force to one column */ NextArg(XtNdefaultColumns, 1); /* ditto */ NextArg(XtNwidth, 150); NextArg(XtNheight, 200); word_list = XtCreateManagedWidget("word_list", figListWidgetClass, spell_viewport, Args, ArgCount); XtAddCallback(word_list, XtNcallback, spell_select_word, (XtPointer) NULL); /* now an ascii widget to put the correct word into */ FirstArg(XtNeditType, XawtextRead); /* make uneditable until user selects a misspelled word */ NextArg(XtNsensitive, False); /* start insensitive */ NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 1); NextArg(XtNfromHoriz, spell_viewport); /* to the right of the viewport */ NextArg(XtNwidth, 150); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); correct_word = XtCreateManagedWidget("correct_word", asciiTextWidgetClass, form, Args, ArgCount); /* "Return" corrects word */ XtOverrideTranslations(correct_word, XtParseTranslationTable(spell_text_translations)); /* focus keyboard on text widget */ XtSetKeyboardFocus(form, correct_word); /* now "Correct" button to the right */ FirstArg(XtNlabel, "Correct"); NextArg(XtNsensitive, False); /* start insensitive */ NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 1); NextArg(XtNfromHoriz, correct_word); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); correct_button = XtCreateManagedWidget("correct", commandWidgetClass, form, Args, ArgCount); XtAddCallback(correct_button, XtNcallback, (XtCallbackProc) spell_correct_word, (XtPointer) NULL); /* make a re-check spelling button at bottom of whole panel */ FirstArg(XtNlabel, "Recheck"); NextArg(XtNfromVert, spell_viewport); NextArg(XtNsensitive, False); /* insensitive to start */ NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); recheck_button = XtCreateManagedWidget("recheck", commandWidgetClass, form, Args, ArgCount); XtAddCallback(recheck_button, XtNcallback, (XtCallbackProc) spell_check, (XtPointer) NULL); /* make dismiss button to the right of the recheck button */ FirstArg(XtNlabel, "Dismiss"); NextArg(XtNfromVert, spell_viewport); NextArg(XtNfromHoriz, recheck_button); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); dismiss_button = XtCreateManagedWidget("dismiss", commandWidgetClass, form, Args, ArgCount); XtAddCallback(dismiss_button, XtNcallback, (XtCallbackProc) spell_panel_dismiss, (XtPointer) NULL); /* install accelerators for the dismiss function */ XtInstallAccelerators(form, dismiss_button); XtInstallAccelerators(word_list, dismiss_button); } XtPopup(spell_check_panel, XtGrabExclusive); /* if the file message window is up add it to the grab */ file_msg_add_grab(); XSetWMProtocols(tool_d, XtWindow(spell_check_panel), &wm_delete_window, 1); set_cmap(XtWindow(spell_check_panel)); }
/************************************************************************** ... **************************************************************************/ void x_main(int argc, char *argv[]) { int i; Pixmap icon_pixmap; XtTranslations TextFieldTranslations; /* include later - pain to see the warning at every run */ /* XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); */ toplevel = XtVaAppInitialize( &app_context, /* Application context */ "Freeciv", /* application class name */ NULL, 0, /* command line option list */ &argc, argv, /* command line args */ fallback_resources, /* for missing app-defaults file */ XtNallowShellResize, True, NULL); /* terminate varargs list */ XtGetApplicationResources(toplevel, &appResources, resources, XtNumber(resources), NULL, 0); display = XtDisplay(toplevel); screen_number=XScreenNumberOfScreen(XtScreen(toplevel)); display_depth=DefaultDepth(display, screen_number); root_window=DefaultRootWindow(display); if(appResources.usingFallback) { log(LOG_NORMAL, "Application defaults file wasn't found. Using fallback resources"); } /* XSynchronize(display, 1); XSetErrorHandler(myerr);*/ display_color_type=get_visual(); if(display_color_type!=COLOR_DISPLAY) { log(LOG_FATAL, "only color displays are supported for now..."); /* exit(1); */ } icon_pixmap = XCreateBitmapFromData(display, RootWindowOfScreen(XtScreen(toplevel)), freeciv_bits, freeciv_width, freeciv_height ); XtVaSetValues(toplevel, XtNiconPixmap, icon_pixmap, NULL); civ_gc = XCreateGC(display, root_window, 0, NULL); { XGCValues values; values.foreground = 0; values.background = 0; fill_bg_gc= XCreateGC(display, root_window, GCForeground | GCBackground, &values); } init_color_system(); load_intro_gfx(); load_tile_gfx(); setup_widgets(); XtSetKeyboardFocus(bottom_form, inputline_text); XtSetKeyboardFocus(below_menu_form, map_canvas); TextFieldTranslations = XtParseTranslationTable /*BLAH!*/ ("<Key>Return: inputline-return()"); XtOverrideTranslations(inputline_text, TextFieldTranslations); XtAppAddActions(app_context, Actions, XtNumber(Actions)); XtAddCallback(map_horizontal_scrollbar, XtNjumpProc, scrollbar_jump_callback, NULL); XtAddCallback(map_vertical_scrollbar, XtNjumpProc, scrollbar_jump_callback, NULL); XtAddCallback(map_horizontal_scrollbar, XtNscrollProc, scrollbar_scroll_callback, NULL); XtAddCallback(map_vertical_scrollbar, XtNscrollProc, scrollbar_scroll_callback, NULL); XtAddCallback(turn_done_button, XtNcallback, end_turn_callback, NULL); XtRealizeWidget(toplevel); x_input_id=XtAppAddInput(app_context, aconnection.sock, (XtPointer) XtInputReadMask, (XtInputCallbackProc) get_net_input, NULL); x_interval_id=XtAppAddTimeOut(app_context, 500, (XtTimerCallbackProc)timer_callback, NULL); map_canvas_store=XCreatePixmap(display, XtWindow(map_canvas), 510, 300, display_depth); map_canvas_store_twidth=510/30; map_canvas_store_theight=300/30; overview_canvas_store_width=2*80; overview_canvas_store_height=2*50; overview_canvas_store=XCreatePixmap(display, XtWindow(overview_canvas), overview_canvas_store_width, overview_canvas_store_height, display_depth); XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_WHITE]); XFillRectangle(display, overview_canvas_store, fill_bg_gc, 0, 0, overview_canvas_store_width, overview_canvas_store_height); single_tile_pixmap_width=30; single_tile_pixmap_height=30; single_tile_pixmap=XCreatePixmap(display, XtWindow(overview_canvas), single_tile_pixmap_width, single_tile_pixmap_height, display_depth); for(i=0; i<4; i++) unit_below_pixmap[i]=XCreatePixmap(display, XtWindow(overview_canvas), 30, 30, display_depth); set_bulp_sol_goverment(0, 0, 0); XtAppMainLoop(app_context); }
void xGRask( XEvent *event, int n ) { extern char *xgrLabelTable[][XGRLABMAXTEXTS]; extern Display *display; extern GRAWIDGETS grawidgets; extern GRAWINDOWS grawindows; extern GRAGLOB graglob; extern GRAFOBJ *grafObj; static char *antwort; WCVALUE a, b; short m; GRAFOBJ obj; int typ; Boolean redraw; char *ptr; unsigned int width, height; Arg args[2]; switch (n) { case BUTTONDEFINE_GRID: ptr = FRAGE_GRID0; break; case BUTTONDEFINE_PICKBOX: ptr = FRAGE_PICKBOX0; break; case BUTTONDEFINE_DRAWAREA: ptr = FRAGE_DRAWAREA0; break; case BUTTONDEFINE_POINTS: ptr = FRAGE_POINTS0; break; } typ = graglob.eingabe; if (typ == 0) { XmTextSetString(grawidgets.frage, ptr); XtSetKeyboardFocus(grawidgets.textfeld, grawidgets.antwort); graglob.eingabe = 1; } else if (typ == 1) { if (event->xany.window == XtWindow(grawidgets.antwort)) { antwort = XmTextGetString(grawidgets.antwort); switch (n) { case BUTTONDEFINE_GRID: redraw = xGRvalues(&graglob.griddist, antwort, XGRMM); if (graglob.griddist > 0.) { graglob.showGrid = True; } else { graglob.showGrid = False; } break; case BUTTONDEFINE_PICKBOX: m = graglob.pickbox.x; redraw = xGRvalues(&m, antwort, XGRPIXEL); graglob.pickbox.x = m; graglob.pickbox.y = m; if (graglob.pickbox.x > 0) { graglob.showPickbox = True; } else { graglob.showPickbox = False; } redraw = False; break; case BUTTONDEFINE_DRAWAREA: if (strcmp(antwort, "A0")) { graglob.Limitx = 1189; graglob.Limity = 841; } if (strcmp(antwort, "A1")) { graglob.Limitx = 841; graglob.Limity = 594; } if (strcmp(antwort, "A2")) { graglob.Limitx = 594; graglob.Limity = 420; } if (strcmp(antwort, "A3")) { graglob.Limitx = 420; graglob.Limity = 297; } if (strcmp(antwort, "A4")) { graglob.Limitx = 297; graglob.Limity = 210; } if (strcmp(antwort, "A5")) { graglob.Limitx = 210; graglob.Limity = 148; } if (sscanf(antwort, "%f &f", &a, &b) == 2) { if (a>0.0 && a<32000.0 && b>0.0 && b<32000.0) { graglob.Limitx = a; graglob.Limity = b; } } redraw = True; graglob.Limitx = (short)(graglob.Limitx*graglob.xfak); graglob.Limity = (short)(graglob.Limity*graglob.yfak); /* 1.Graphikdatensatz ist immer der */ /* Drawing Area Record 'D' */ grafObj[0].was = OBJ_DRAWINGAREA; grafObj[0].gc1 = 0; grafObj[0].gc2 = 0; grafObj[0].gc3 = 0; grafObj[0].text = 0; grafObj[0].xpoints[0] = graglob.Limitx; grafObj[0].xpoints[1] = graglob.Limity; grafObj[0].anzRegionPoints = 4; grafObj[0].regionPoint[0].p.x = 0; grafObj[0].regionPoint[0].p.y = 0; grafObj[0].regionPoint[1].p.x = graglob.Limitx; grafObj[0].regionPoint[1].p.y = 0; grafObj[0].regionPoint[2].p.x = graglob.Limitx; grafObj[0].regionPoint[2].p.y = graglob.Limity; grafObj[0].regionPoint[3].p.x = 0; grafObj[0].regionPoint[3].p.y = graglob.Limity; width = (unsigned)(graglob.Limitx); height = (unsigned)(graglob.Limity); XtSetArg(args[0], XmNwidth, width); XtSetArg(args[1], XmNheight, height); XtSetValues(grawidgets.graphik, args, 2); break; case BUTTONDEFINE_POINTS: redraw = xGRvalues(&graglob.RadiusPoints, antwort, XGRPIXEL); if (graglob.RadiusPoints > 0) { graglob.showPoints = True; } else { graglob.showPoints = False; } break; } XmTextSetString(grawidgets.frage, ""); XmTextSetString(grawidgets.antwort, ""); graglob.eingabe = 0; graglob.aktbox = BUTTONNONE; graglob.akttog = BUTTONNONE; XtFree((void *)antwort); if (redraw) { XClearArea(display, grawindows.graphik, 0, 0, 0, 0, True); } } } }
int main(int argc, char *argv[]) { Boolean exists; char *filename; FileAccess file_access; Widget source; XtAppContext appcon; Boolean show_dir; xedit_flist_item *first_item; unsigned int i, lineno; lineno = 0; show_dir = FALSE; first_item = NULL; topwindow = XtAppInitialize(&appcon, "Xedit", NULL, 0, &argc, argv, NULL, NULL, 0); XtAppAddActions(appcon, actions, XtNumber(actions)); XtOverrideTranslations(topwindow, XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()")); XtGetApplicationResources(topwindow, (XtPointer) &app_resources, resources, XtNumber(resources), NULL, 0); CurDpy = XtDisplay(topwindow); XawSimpleMenuAddGlobalActions(appcon); XtRegisterGrabAction(PopupMenu, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync); makeButtonsAndBoxes(topwindow); StartHints(); StartFormatPosition(); (void)StartHooks(appcon); if (position_format_mask == 0) { for (i = 0; i < 3; i++) XtRemoveCallback(texts[i], XtNpositionCallback, PositionChanged, NULL); } XtRealizeWidget(topwindow); #ifndef __UNIXOS2__ XeditLispInitialize(); #endif options_popup = XtCreatePopupShell("optionsMenu", simpleMenuWidgetClass, topwindow, NULL, 0); XtRealizeWidget(options_popup); XtAddCallback(XtCreateManagedWidget("ispell", smeBSBObjectClass, options_popup, NULL, 0), XtNcallback, IspellCallback, NULL); CreateEditPopup(); wm_delete_window = XInternAtom(XtDisplay(topwindow), "WM_DELETE_WINDOW", False); (void)XSetWMProtocols(XtDisplay(topwindow), XtWindow(topwindow), &wm_delete_window, 1); /* This first call is just to save the default font and colors */ UpdateTextProperties(0); if (argc > 1) { xedit_flist_item *item; Arg args[2]; unsigned int num_args; for (i = 1; i < argc; i++) { struct stat st; if (argv[i][0] == '+') { char *endptr; lineno = strtol(argv[i], &endptr, 10); /* Don't warn about incorrect input? */ if (*endptr) lineno = 0; continue; } filename = ResolveName(argv[i]); if (filename == NULL || FindTextSource(NULL, filename) != NULL) continue; num_args = 0; if (stat(filename, &st) == 0 && !S_ISREG(st.st_mode)) { if (S_ISDIR(st.st_mode)) { if (!first_item) { char path[BUFSIZ + 1]; strncpy(path, filename, sizeof(path) - 2); path[sizeof(path) - 2] = '\0'; if (*path) { if (path[strlen(path) - 1] != '/') strcat(path, "/"); } else strcpy(path, "./"); XtSetArg(args[0], XtNlabel, ""); XtSetValues(dirlabel, args, 1); SwitchDirWindow(True); DirWindowCB(dirwindow, path, NULL); show_dir = True; } continue; } } switch (file_access = CheckFilePermissions(filename, &exists)) { case NO_READ: if (exists) XeditPrintf("File %s exists, and could not be opened for " "reading.\n", argv[i]); else XeditPrintf("File %s does not exist, and the directory " "could not be opened for writing.\n", argv[i]); break; case READ_OK: XtSetArg(args[num_args], XtNeditType, XawtextRead); num_args++; XeditPrintf("File %s opened READ ONLY.\n", argv[i]); break; case WRITE_OK: XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; XeditPrintf("File %s opened read - write.\n", argv[i]); break; } if (file_access != NO_READ) { int flags; if (exists) { flags = EXISTS_BIT; XtSetArg(args[num_args], XtNstring, filename);num_args++; } else { flags = 0; XtSetArg(args[num_args], XtNstring, NULL); num_args++; } source = XtVaCreateWidget("textSource", international ? multiSrcObjectClass : asciiSrcObjectClass, topwindow, XtNtype, XawAsciiFile, XtNeditType, XawtextEdit, NULL, NULL); XtSetValues(source, args, num_args); item = AddTextSource(source, argv[i], filename, flags, file_access); XtAddCallback(item->source, XtNcallback, SourceChanged, (XtPointer)item); if (exists && file_access == WRITE_OK) { item->mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); item->mtime = st.st_mtime; } if (!first_item && !show_dir) first_item = item; ResetSourceChanged(item); } } } if (!flist.pixmap && strlen(app_resources.changed_pixmap_name)) { XrmValue from, to; from.size = strlen(app_resources.changed_pixmap_name); from.addr = app_resources.changed_pixmap_name; to.size = sizeof(Pixmap); to.addr = (XtPointer)&(flist.pixmap); XtConvertAndStore(flist.popup, XtRString, &from, XtRBitmap, &to); } if (first_item == NULL) { XtSetKeyboardFocus(topwindow, filenamewindow); XtVaSetValues(textwindow, XtNwrap, XawtextWrapLine, NULL); } else { SwitchTextSource(first_item); XtSetKeyboardFocus(topwindow, textwindow); if (lineno) { XawTextPosition position; source = XawTextGetSource(textwindow); position = RSCAN(XawTextGetInsertionPoint(textwindow), lineno, False); position = LSCAN(position, 1, False); XawTextSetInsertionPoint(textwindow, position); } } XtAppMainLoop(appcon); return EXIT_SUCCESS; }
static void build_cartridge_dialog(void) { char *button_title; char *filename = util_concat(_("File name"), ":", NULL); if (cartridge_dialog != NULL) { return; } cartridge_dialog = ui_create_transient_shell(_ui_top_level, "cartridgeDialog"); cartridge_dialog_pane = XtVaCreateManagedWidget("cartridgeDialogPane", panedWidgetClass, cartridge_dialog, NULL); file_name_form = XtVaCreateManagedWidget("fileNameForm", formWidgetClass, cartridge_dialog_pane, XtNshowGrip, False, NULL); file_name_label = XtVaCreateManagedWidget("fileNameLabel", labelWidgetClass, file_name_form, XtNjustify, XtJustifyLeft, XtNlabel, filename, XtNborderWidth, 0, NULL); lib_free(filename); #ifndef ENABLE_TEXTFIELD file_name_field = XtVaCreateManagedWidget("fileNameField", asciiTextWidgetClass, file_name_form, XtNfromHoriz, file_name_label, XtNwidth, 200, XtNtype, XawAsciiString, XtNeditType, XawtextEdit, NULL); #else file_name_field = XtVaCreateManagedWidget("fileNameField", textfieldWidgetClass, file_name_form, XtNfromHoriz, file_name_label, XtNwidth, 200, XtNstring, "", /* Otherwise, it does not work correctly. */ NULL); #endif button_title = util_concat(_("Browse"), "...", NULL); browse_button = XtVaCreateManagedWidget("browseButton", commandWidgetClass, file_name_form, XtNfromHoriz, file_name_field, XtNlabel, button_title, NULL); lib_free(button_title); XtAddCallback(browse_button, XtNcallback, browse_callback, NULL); button_box = XtVaCreateManagedWidget("buttonBox", boxWidgetClass, cartridge_dialog_pane, XtNshowGrip, False, NULL); save_button = XtVaCreateManagedWidget("saveButton", commandWidgetClass, button_box, XtNlabel, _("Save"), NULL); XtAddCallback(save_button, XtNcallback, save_callback, NULL); cancel_button = XtVaCreateManagedWidget("cancelButton", commandWidgetClass, button_box, XtNlabel, _("Cancel"), NULL); XtAddCallback(cancel_button, XtNcallback, cancel_callback, NULL); XtSetKeyboardFocus(cartridge_dialog_pane, file_name_field); }
void FocusOnWidget (Option *opt, DialogClass dlg) { UnCaret(); XtSetKeyboardFocus(shells[dlg], opt->handle); }