/* ** Process a command to go to a marked selection. Expects the user to ** continue the command by typing a label character. Handles both correct ** user behavior (type a character a-z) or bad behavior (do nothing or type ** something else). */ void BeginGotoMarkCommand(WindowInfo *window, int extend) { XtInsertEventHandler(window->lastFocus, KeyPressMask, False, extend ? gotoMarkExtendKeyCB : gotoMarkKeyCB, window, XtListHead); window->markTimeoutID = XtAppAddTimeOut( XtWidgetToApplicationContext(window->shell), 4000, markTimeoutProc, window->lastFocus); }
static void displayDTIcon(DTIconRec *dticon) { XGCValues xgcv; GC shapeGC; Window shellwin; XmString labelstr; Dimension labelwidth, labelheight, togglewidth, toggleheight; Dimension tgl_offs_x, lbl_offs_x, lbl_offs_y; Atom targets[2]; Boolean is_file = False; int i; targets[0] = dragAtoms.file; targets[1] = dragAtoms.filelist; drop_args[0].value = (XtArgVal) targets; dticon->app.form = XtVaCreateManagedWidget("form", xmFormWidgetClass, dticon->cont, XmNtranslations, XtParseTranslationTable(form_translations), XmNbackground, resources.dticon_color, XmNforeground, resources.label_color, XmNborderWidth, 0, XmNshadowThickness, 0, XmNhighlightThickness, 0, XmNx, 0, XmNy, 0, NULL); if (dticon->app.fname[0]) { char path[MAXPATHLEN]; struct stat stats; int errfl = 0; if (dticon->app.directory[0]) { strcpy(path, dticon->app.directory); fnexpand(path); errfl = chdir(path); } else errfl = chdir(user.home); if (!errfl && !(stat(dticon->app.fname, &stats)) && S_ISREG(stats.st_mode)) is_file = True; } if (is_file) { for (i=0; i < XtNumber(file_popup_menu); i++) file_popup_menu[i].callback_data = dticon; dticon->popup = BuildMenu(dticon->app.form, XmMENU_POPUP, "Button Actions", 0, False, file_popup_menu); if (resources.auto_save) XtVaSetValues(file_popup_menu[5].object, XmNsensitive, False, NULL); } else { for (i=0; i < XtNumber(file_popup_menu); i++) popup_menu[i].callback_data = dticon; dticon->popup = BuildMenu(dticon->app.form, XmMENU_POPUP, "Button Actions", 0, False, popup_menu); if (resources.auto_save) XtVaSetValues(popup_menu[3].object, XmNsensitive, False, NULL); } labelstr = XmStringCreateLocalized(dticon->app.name); labelwidth = XmStringWidth((XmFontList) resources.icon_font, labelstr) + 2; togglewidth = dticon->app.icon_pm.width; toggleheight = dticon->app.icon_pm.height; if (labelwidth > togglewidth) { tgl_offs_x = (labelwidth - togglewidth) / 2; lbl_offs_x = 0; } else { tgl_offs_x = 0; lbl_offs_x = (togglewidth - labelwidth) / 2; } lbl_offs_y = dticon->app.icon_pm.height + 2; dticon->app.toggle = XtVaCreateManagedWidget("picture", xmLabelWidgetClass, dticon->app.form, XmNlabelType, XmPIXMAP, XmNlabelPixmap, dticon->app.icon_pm.bm, XmNtranslations, trans, XmNborderWidth, 0, XmNhighlightThickness, 0, XmNbackground, resources.dticon_color, XmNforeground, resources.label_color, XmNx, tgl_offs_x, XmNy, 0, NULL); /* RBW - 2001/08/15 */ XtInsertEventHandler(dticon->app.toggle, EnterWindowMask|LeaveWindowMask, False, (XtEventHandler)CatchEntryLeave2, (XtPointer)0, XtListHead); dticon->app.label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, dticon->app.form, XmNlabelString, labelstr, XmNfontList, resources.icon_font, XmNtranslations, trans, XmNbackground, resources.dticon_color, XmNforeground, resources.label_color, XmNborderWidth, 0, XmNhighlightThickness, 0, XmNx, lbl_offs_x, XmNy, lbl_offs_y, NULL); /* RBW - 2001/08/15 */ XtInsertEventHandler(dticon->app.label, EnterWindowMask|LeaveWindowMask, False, (XtEventHandler)CatchEntryLeave2, (XtPointer)0, XtListHead); XmStringFree(labelstr); XtRealizeWidget(dticon->shell); shellwin = XtWindow(dticon->shell); XtVaGetValues(dticon->app.label, XmNwidth, &labelwidth, XmNwidth, &labelheight, NULL); labelheight += 2; dticon->label_mask = XCreatePixmap(dpy, shellwin, labelwidth, labelheight, 1); shapeGC = XCreateGC(dpy, dticon->label_mask, 0, &xgcv); XSetForeground(dpy, shapeGC, 1); XFillRectangle(dpy, dticon->label_mask, shapeGC, 0, 0, labelwidth, labelheight); XFreeGC(dpy, shapeGC); if (dticon->app.icon_pm.mask == None) { dticon->app.icon_pm.mask = XCreatePixmap(dpy, shellwin, dticon->app.icon_pm.width, dticon->app.icon_pm.height, 1); shapeGC = XCreateGC(dpy, dticon->app.icon_pm.mask, 0, &xgcv); XSetForeground(dpy, shapeGC, 1); XFillRectangle(dpy, dticon->app.icon_pm.mask, shapeGC, 0, 0, togglewidth, toggleheight); XFreeGC(dpy, shapeGC); } XShapeCombineMask(dpy, shellwin, ShapeBounding, tgl_offs_x + 2, 2, dticon->app.icon_pm.mask, ShapeSet); XShapeCombineMask(dpy, shellwin, ShapeBounding, lbl_offs_x + 2, lbl_offs_y + 2, dticon->label_mask, ShapeUnion); XShapeCombineMask(dpy, XtWindow(dticon->app.form), ShapeClip, tgl_offs_x + 2, 2, dticon->app.icon_pm.mask, ShapeSet); XShapeCombineMask(dpy, XtWindow(dticon->app.form), ShapeClip, lbl_offs_x + 2, lbl_offs_y + 2, dticon->label_mask, ShapeUnion); XShapeCombineMask(dpy, XtWindow(dticon->app.toggle), ShapeClip, 2, 2, dticon->app.icon_pm.mask, ShapeSet); XtVaGetValues(dticon->shell, XmNwidth, &dticon->width, XmNheight, &dticon->height, NULL); dticon->drop_pixmap = XCreatePixmap(dpy, shellwin, dticon->width, dticon->height, DefaultDepth(dpy, DefaultScreen(dpy))); shapeGC = XCreateGC(dpy, dticon->drop_pixmap, 0, &xgcv); XSetForeground(dpy, shapeGC, resources.drop_color); XFillRectangle(dpy, dticon->drop_pixmap, shapeGC, 0, 0, dticon->width, dticon->height); XFreeGC(dpy, shapeGC); drop_args[4].value = (XtArgVal) dticon->drop_pixmap; if (dticon->app.drop_action[0]) XmDropSiteRegister(dticon->app.form, drop_args, XtNumber(drop_args)); }
void * appMakeSpellTool( APP_WIDGET spellOption, EditApplication * ea, const char * widgetName, APP_BITMAP_IMAGE iconPixmap, APP_BITMAP_MASK iconMask, AppToolDestroy destroy, SpellToolFindNext findNext, SpellToolCorrect correct, void * target ) { AppSpellTool * ast; APP_WIDGET dictionaryFrame; const int userResizable= 1; static AppSpellToolResources astr; static int gotResources; if ( ! gotResources ) { appGuiGetResourceValues( &gotResources, ea, (void *)&astr, APP_SpellToolResourceTable, sizeof(APP_SpellToolResourceTable)/ sizeof(AppConfigurableResource) ); } ast= (AppSpellTool *)malloc( sizeof(AppSpellTool) ); if ( ! ast ) { XDEB(ast); return (void *)0; } ast->astApplication= ea; ast->astResources= &astr; ast->astDestroy= destroy; ast->astFindNext= findNext; ast->astCorrect= correct; ast->astTarget= target; ast->astPrivateDictionaries= astr.astrPrivateDictionaries; ast->astSystemDictionaries= astr.astrSystemDictionaries; ast->astDictionaryContexts= (AppSpellCheckContext *)0; ast->astDictionaryCount= 0; ast->astCurrentDictionary= -1; appInitOptionmenu( &(ast->astDictionaryOptionmenu) ); appSpellGetDictionaries( ast, &astr ); appMakeVerticalTool( &(ast->astTopWidget), &(ast->astMainWidget), ea, iconPixmap, iconMask, widgetName, userResizable, spellOption, appCloseSpellTool, (void *)ast ); dictionaryFrame= appSpellMakeDictionaryFrame( ast->astMainWidget, &astr, ast ); ast->astGuessList= appSpellGuessList( ast->astMainWidget, &astr, ast ); # ifdef USE_MOTIF XtAddCallback( ast->astGuessList, XmNdefaultActionCallback, appSpellToolCorrect, (void *)ast ); # endif appMakeTextInColumn( &(ast->astWordText), ast->astMainWidget, 0, 1 ); appGuiSetTypingCallbackForText( ast->astWordText, appSpellCorrectionTyped, (void *)ast ); appSpellMakeButtonRows( ast->astMainWidget, &astr, ast ); # ifdef USE_MOTIF XtInsertEventHandler( ast->astGuessList, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); XtInsertEventHandler( ast->astWordText, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); XtInsertEventHandler( ast->astLearnButton, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); XtInsertEventHandler( ast->astForgetButton, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); XtInsertEventHandler( ast->astCorrectButton, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); XtInsertEventHandler( ast->astGuessButton, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); XtInsertEventHandler( ast->astIgnoreButton, KeyReleaseMask, False, appSpellToolCancel, (void *)ast, XtListHead ); # endif appSpellFillDictionaryMenu( ast, &astr ); appShowShellWidget( ast->astTopWidget ); appOptionmenuRefreshWidth( &(ast->astDictionaryOptionmenu) ); appSpellToolSomethingFound( ast, 0 ); appSpellToolGotAlternative( ast, 0 ); return (void *)ast; }
Widget create_statusline( #ifdef MOTIF Widget parent #else void #endif ) { #ifndef MOTIF Position vport_h; Position clip_x; Position clip_w; static Position my_h = 0; #endif /* * FIXME: is there a better way to set the y position depending on * the height of the widget? * It doesn't work to change the value of XtNy *after* creating * the widget! */ if (!initialized) { #ifndef MOTIF /* * determine height of statusline (depending on the font used). * This is not changeable at runtime, so it's determined once and * for all at program start. */ statusline = XtVaCreateWidget("statusline", labelWidgetClass, globals.widgets.vport_widget, XtNlabel, (XtArgVal) "test", NULL); XtVaGetValues(statusline, XtNheight, &my_h, NULL); m_statusline_h = my_h; XtDestroyWidget(statusline); #endif initialized = True; /* initialize g_string_savebuf */ sprintf(g_string_savebuf, "This is xdvik %s", XDVI_TERSE_VERSION_INFO); } #ifndef MOTIF /* determine position and width of statusline */ XtVaGetValues(globals.widgets.clip_widget, XtNx, &clip_x, XtNwidth, &clip_w, NULL); XtVaGetValues(globals.widgets.vport_widget, XtNheight, &vport_h, NULL); if (vport_h - my_h <= 0) { XDVI_FATAL((stderr, "Window height too small for statusline (minimum value: %d).", my_h)); return NULL; } statusline = XtVaCreateManagedWidget("statusline", labelWidgetClass, globals.widgets.vport_widget, XtNlabel, (XtArgVal) g_string_savebuf, XtNwidth, clip_w, XtNx, clip_x - 1, /* so that left border becomes invisible */ XtNy, vport_h - my_h, XtNjustify, XtJustifyLeft, /* same as for the buttons line */ XtNborder, (XtArgVal) resource.fore_Pixel, NULL); #else statusline = XtVaCreateManagedWidget("statusline", xmTextFieldWidgetClass, parent, XmNalignment, XmALIGNMENT_END, XmNdepth, (XtArgVal) G_depth, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 1, XmNrightOffset, 1, XmNbottomOffset, 1, XmNtopOffset, 0, XmNcursorPositionVisible, False, XmNautoShowCursorPosition, False, XmNmarginWidth, 4, XmNmarginHeight, 1, XmNeditable, False, XmNtraversalOn, False, XmNvalue, g_string_savebuf, NULL); /* Block processing of most interactive events on this widget, except * for button events that should navigate the page history. */ XtInsertEventHandler(statusline, KeyPressMask | KeyReleaseMask | PointerMotionMask| PointerMotionHintMask | ButtonMotionMask | #if !MOTIF ButtonPressMask | ButtonReleaseMask | #endif FocusChangeMask, /* ButtonPressMask | ButtonReleaseMask | */ /* PointerMotionMask| PointerMotionHintMask | */ /* ButtonMotionMask | */ True, block_event_callback, (XtPointer)0, 0); #if MOTIF XtInsertEventHandler(statusline, /* suboptimal, but needs to be release not press * since we want to query the current cursor position, * and that may not be set yet in the press event(?). */ ButtonReleaseMask, True, handle_statusline_event, (XtPointer)g_string_savebuf, XtListTail); #endif /* MOTIF */ #endif return statusline; }