static void placeDTIcon(DTIconRec *dticon) { Dimension width; XmString labelstr; String icon_pos; if (x0 == -1) { /* Seems to be necessary at least under HP-UX: */ icon_pos = XtNewString(resources.icon_pos); sscanf(icon_pos, "%d%d", &x0, &y0); XTFREE(icon_pos); if (x0 < 0) x0 += winInfo.rootWidth - DTICONWIDTH; if (y0 < 0) y0 += winInfo.rootHeight - DTICONHEIGHT; } dticon->x = x0; dticon->y = y0; dticon->width = dticon->app.icon_pm.width; dticon->height = dticon->app.icon_pm.height; labelstr = XmStringCreateLocalized(dticon->app.name); width = XmStringWidth((XmFontList) resources.icon_font, labelstr) + 2; dticon->height += XmStringWidth((XmFontList) resources.icon_font, labelstr) + 4; if (width > dticon->width) dticon->width = width; dticon->height += 2 * MARGIN; dticon->width += 2 * MARGIN; while (!tryPosition(dticon)); dticon->x += MARGIN; dticon->y += MARGIN; }
void docWrapModifyCB( Widget w, XtPointer client_data, XtPointer call_data) { char *cb, *ptr; char buf[2]; int length; Boolean res; Dimension doc_edge, char_width; Position x, y; XmRenderTable rtbl; XmString s; XmTextPosition pos; XmTextVerifyCallbackStruct *acs; acs = (XmTextVerifyCallbackStruct *) call_data; cb = "docModifyCB"; if (XmCR_MODIFYING_TEXT_VALUE != acs->reason) return; length = acs->text->length; ptr = acs->text->ptr; if (0 == length) return; pos = acs->startPos; res = XmTextPosToXY(w, pos, &x, &y); if (False == res) { fprintf(stderr, "Could not grab character position coordinates, ignoring.\n"); return; } XtVaGetValues(w, XmNwidth, &doc_edge, XmNrenderTable, &rtbl, NULL); if (1 == length) { buf[0] = *(acs->text->ptr); buf[1] = '\0'; s = XmStringCreateLocalized(buf); char_width = XmStringWidth(rtbl, s); if (doc_edge <= x + 2*char_width) { XtRealloc(acs->text->ptr, ++length); (acs->text->ptr)[1] = (acs->text->ptr)[0]; (acs->text->ptr)[0] = '\n'; acs->text->length = length; } XmStringFree(s); return; } batch_wrap(w, cb, acs->text->ptr, &length, pos); acs->text->length = length; }
static Boolean Test2(Widget W) { Dimension h,w; Dimension ch,cw,bw,mw; Position cx,cy; WidgetList kids; Cardinal numkids; int i; XmString string; XmFontList font_list; fprintf(stderr,"Test 2 starting...\n"); XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, NULL); XtVaSetValues(kids[TOPLABEL], XmNbottomAttachment, XmATTACH_NONE, NULL); for (i = 1; i<numkids; i++) { XtUnmanageChild(kids[i]); } XtVaGetValues(kids[TOPLABEL], XmNlabelString, &string, XmNfontList, &font_list, XmNborderWidth, &bw, XmNmarginWidth, &mw, XmNwidth, &cw, NULL); ExpectedResults[1].width = XmStringWidth(font_list,string) + 2 * mw; XmStringFree(string); ExpectedResults[0].request_mode = CWWidth | CWHeight; ExpectedResults[0].x = 0; ExpectedResults[0].y = 0; ExpectedResults[0].width = ExpectedResults[1].width + 2 * bw; ExpectedResults[0].height = 19; ExpectedResults[1].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[1].x = 0; ExpectedResults[1].y = 0; ExpectedResults[1].height = 17; ExpectedResults[2].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[2].request_mode = 0; ExpectedResults[2].x = 0; ExpectedResults[2].y = 0; ExpectedResults[2].width = 0; ExpectedResults[2].height = 0; printf("Test 2 Unmanage all but the first child\n"); FinishTest(W); return(True); }
XFE_MailDownloadView::XFE_MailDownloadView(XFE_Component *toplevel_component, Widget parent, XFE_View *parent_view, MWContext *context, MSG_Pane *parent_pane, MSG_Pane *p) : XFE_MNView(toplevel_component, parent_view, context, p) { Widget form; XmString xmstr = XmStringCreate(XP_GetString(XFE_DOWNLOADING_NEW_MESSAGES), XmFONTLIST_DEFAULT_TAG); XmFontList fontList; form = XtCreateWidget("topArea", xmFormWidgetClass, parent, NULL, 0); m_label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, form, XmNlabelString, xmstr, NULL); m_logo = new XFE_Logo((XFE_Frame*)toplevel_component, form, "logo"); XtVaGetValues(m_label, XmNfontList, &fontList, NULL); // we need more space, or else the window is *tiny* XtVaSetValues(m_label, XmNwidth, XmStringWidth(fontList, xmstr) * 2, NULL); XmStringFree(xmstr); /* now do the attachments. */ XtVaSetValues(m_label, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, m_logo->getBaseWidget(), XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, m_logo->getBaseWidget(), XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, m_logo->getBaseWidget(), NULL); XtVaSetValues(m_logo->getBaseWidget(), XmNleftAttachment, XmATTACH_NONE, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_NONE, XmNtopAttachment, XmATTACH_FORM, NULL); m_logo->show(); if (!p) setPane(MSG_CreateProgressPane(m_contextData, XFE_MNView::getMaster(), parent_pane)); setBaseWidget(form); }
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)); }
/********************************************************************************** * FUNCTIONS **********************************************************************************/ int video_open(PLOT *plot) { struct videodata *plotdata; Display *dpy; Screen *scr; Widget w, mw, m0, m1, m2, m3; int status = SUCCESS; Dimension width, height; int depth; XGCValues values; unsigned long foreground, background; XmString xmstr, xmstr1; Arg args[10]; int n; plot->plotdata = (void *)calloc(1, sizeof(struct videodata)); plotdata = (struct videodata *)plot->plotdata; plotdata->image = (XImage *)calloc(sizeof(XImage), 1); plotdata->framedata = NULL; plotdata->width = 0; plotdata->height = 0; plotdata->ncomps = 0; plotdata->microsecs_per_frame = 0; plotdata->colormap = defaults.colormap; plotdata->framenum = 0; plotdata->loadedframenum = -1; plot->plot_widget = XtVaCreateManagedWidget("video", xmDrawingAreaWidgetClass, plot->panel->panel_container, XmNheight, defaults.video_height, XmNwidth, defaults.width, XmNmarginHeight, 0, XmNmarginWidth, 0, NULL); XtAddCallback(plot->plot_widget, XmNexposeCallback, video_expose_callback, (XtPointer)plot); XtAddCallback(plot->plot_widget, XmNresizeCallback, video_resize_callback, (XtPointer)plot); w = (Widget)plot->plot_widget; dpy = XtDisplay(w); scr = XtScreen(w); XtVaGetValues(w, XmNheight, &height, XmNwidth, &width, XmNdepth, &depth, XmNforeground, &foreground, XmNbackground, &background, NULL); /* ** Get the font; also, calculate the margins for the axes (this depends on the font size!). ** Store these margins for use later (we might start off without axes, and turn them on later. */ plot->ticklblfont = XmFontListCopy(_XmGetDefaultFontList(w, XmLABEL_FONTLIST)); plot->minoffx = 6 + XmStringWidth(plot->ticklblfont, xmstr = XmStringCreateSimple("-32768")); XmStringFree(xmstr); plot->minoffx2 = 0; plot->minoffy = 0; plot->minoffy2 = 6 + XmStringHeight(plot->ticklblfont, xmstr = XmStringCreateSimple("1")); XmStringFree(xmstr); plot->offx = 0; plot->offy = 0; plot->offx2 = 0; plot->offy2 = 0; plot->width = width; plot->height = height; plot->depth = depth; /* ** Allocate our colors. We use the XCC code that is: ** Copyright 1994,1995 John L. Cwikla ** This allows us to work on any visual, etc. The danger is that ** we may not get the exact colors we ask for... meaning that things ** may not really be as we see them. This is unfortunate, but the ** alternative is to not run at all (the old code crashed). So... */ plotdata->ncolors = MIN(SONO_DEFAULT_MAX_COLORS, MIN(XDisplayCells(dpy, XDefaultScreen(dpy)), MAXCOLORS - RESERVED_COLORS)); plotdata->xcc = XCCCreate(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), TRUE, TRUE, XA_RGB_GRAY_MAP, &(plotdata->cmap)); if (XCCGetNumColors(plotdata->xcc) < plotdata->ncolors) { plotdata->ncolors = XCCGetNumColors(plotdata->xcc); printf("Warning. Using only %d colors.\n", plotdata->ncolors); } (*((colormap[plotdata->colormap]).cmap))(dpy, plotdata->ncolors, plotdata->colors, NULL); /* ** Create the Graphics contexts. ** drawing_GC is for the picture itself. inverse_GC is for erasing. mark_GC is for the subregion marks. */ values.font = getFontStruct(plot->ticklblfont)->fid; values.function = GXcopy; values.plane_mask = AllPlanes; values.foreground = foreground; values.background = background; plotdata->drawing_GC = XtGetGC(w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFont, &values); values.foreground = background; values.background = background; plotdata->inverse_GC = XtGetGC(w, GCForeground | GCBackground, &values); values.function = GXxor; values.plane_mask = foreground ^ background; values.foreground = 0xffffffff; values.background = 0x0; values.line_style = LineSolid; plotdata->mark_GC = XtGetGC(w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineStyle, &values); plotdata->pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), width, height, depth); plotdata->pixmapalloced = TRUE; XFillRectangle(dpy, plotdata->pixmap, plotdata->inverse_GC, 0, 0, width, height); /* ** Create the popup menu ** */ n = 0; XtSetArg(args[n], XmNmenuPost, "<Btn3Down>"); n++; mw = plot->plot_popupmenu_widget = XmCreatePopupMenu(w, "popupmenu", args, n); m0 = XtVaCreateManagedWidget("m0", xmLabelGadgetClass, mw, XmNlabelString, xmstr1 = XmStringCreateSimple("Options"), NULL); XmStringFree(xmstr1); m1 = XtVaCreateManagedWidget("m1", xmSeparatorGadgetClass, mw, NULL); CreateMenuButton(m2, mw, "save", "Save", "Save"); CreateMenuButton(m3, mw, "print", "Print EPS", "Print EPS"); /* ** Register an event handler */ XtAddEventHandler(w, KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask, FALSE, (XtEventHandler) video_event_handler, (XtPointer)plot); plot->plot_display = video_display; plot->plot_set = video_set; plot->plot_close = video_close; plot->plot_print = video_print; plot->plot_playmarker = NULL; plot->plot_showvideoframe = video_showvideoframe; plot->plot_clearmarks = NULL; plot->plot_drawstartmark = NULL; plot->plot_drawstopmark = NULL; plot->plot_conv_pixel_to_time = NULL; plot->plot_save = video_save; plot->plot_event_handler = video_event_handler; plot->plot_play = video_play; plotdata->butgrabbed = FALSE; plot->playmark = -1; plot->markx1 = -1; plot->markx2 = -1; plot->group->needpcm = 1; return status; }
static void da_expose(Widget w, XtPointer client_data, XtPointer call_data) { XExposeEvent *e = &((XmDrawingAreaCallbackStruct *) call_data) ->event->xexpose; XmString *items, *selected_items, out_string, tmp_string; Boolean underline; int item_count, selected_count; Widget list = (Widget) client_data; Dimension width, height, extent, item_extent, string_height; int i; XmFontList font_list; XRectangle clip; /* Extract items, selected items and font from XmList */ XtVaGetValues(list, XmNitems, &items, XmNitemCount, &item_count, XmNselectedItems, &selected_items, XmNselectedItemCount, &selected_count, XmNfontList, &font_list, NULL); XtVaGetValues(w, XmNwidth, &width, XmNheight, &height, NULL); underline = (selected_count > 0); create_gc(w); extent = 0; out_string = NULL; /* * Form list items into a single compound string, inserting * separators where needed to avoid drawing outside the XmDrawingArea */ for (i = 0; i < item_count; i++) { item_extent = XmStringWidth(font_list, items[i]); if (out_string != NULL && (extent + item_extent > width)) { extent = 0; out_string = string_append(out_string, XmStringSeparatorCreate()); } tmp_string = XmStringConcat(out_string, items[i]); XmStringFree(out_string); out_string = tmp_string; extent = extent + item_extent; } string_height = XmStringHeight(font_list, out_string); clip.x = e->x; clip.y = e->y; clip.width = e->width; clip.height = e->height; XSetClipRectangles(XtDisplay(w), gc, 0, 0, &clip, 1, YXBanded); /* Draw compound string, underlining the selected item if any */ if (underline) XmStringDrawUnderline(XtDisplay(w), XtWindow(w), font_list, out_string, gc, 0, (height - string_height) / 2, width, XmALIGNMENT_CENTER, XmSTRING_DIRECTION_L_TO_R, NULL, selected_items[0]); else XmStringDraw(XtDisplay(w), XtWindow(w), font_list, out_string, gc, 0, (height - string_height) / 2, width, XmALIGNMENT_CENTER, XmSTRING_DIRECTION_L_TO_R, NULL); XmStringFree(out_string); }
static int _CellAction(XmLGridCell cell, Widget w, XmLGridCallbackStruct *cbs) { XmLTreeWidget t; XmLTreeRow row; XmLGridColumn col; XmLGridWidgetClass sc; XmLGridCellActionProc cellActionProc; XmLGridCellRefValues *cellValues; XmLGridCellIcon *icon; /* XRectangle *rect, cRect;*/ int ret, h, isTreeCell; t = (XmLTreeWidget)w; if (cbs->rowType == XmCONTENT && cbs->columnType == XmCONTENT && cbs->column == 0) isTreeCell = 1; else isTreeCell = 0; sc = (XmLGridWidgetClass)xmlTreeWidgetClass->core_class.superclass; cellActionProc = sc->grid_class.cellActionProc; ret = 0; switch (cbs->reason) { case XmCR_CELL_DRAW: if (isTreeCell) DrawIconCell(cell, w, cbs->row, cbs->clipRect, cbs->drawInfo); else ret = cellActionProc(cell, w, cbs); break; case XmCR_PREF_HEIGHT: ret = cellActionProc(cell, w, cbs); if (isTreeCell) { cellValues = cell->cell.refValues; if (cellValues->type != XmICON_CELL) return 0; icon = (XmLGridCellIcon *)cell->cell.value; h = 4 + 16 + cellValues->topMargin + cellValues->bottomMargin; if (icon && icon->pix.pixmap == XmUNSPECIFIED_PIXMAP && ret < h) ret = h; } break; case XmCR_PREF_WIDTH: if (isTreeCell) { cellValues = cell->cell.refValues; if (cellValues->type != XmICON_CELL) return 0; icon = (XmLGridCellIcon *)cell->cell.value; col = (XmLGridColumn)cbs->object; row = (XmLTreeRow)XmLGridGetRow(w, XmCONTENT, cbs->row); if (row->tree.stringWidthValid == False) { if (icon && icon->string) row->tree.stringWidth = XmStringWidth(cellValues->fontList, icon->string); else row->tree.stringWidth = 0; row->tree.stringWidthValid = True; } ret = 4 + cellValues->leftMargin + t->tree.levelSpacing * 2 * row->tree.level + XmLICON_SPACING + row->tree.stringWidth + cellValues->rightMargin; if (!icon) ret += 16; else if (icon->pix.pixmap == XmUNSPECIFIED_PIXMAP) ret += 16; else ret += icon->pix.width; if (!row->grid.height) ret = 0; } else ret = cellActionProc(cell, w, cbs); break; default: ret = cellActionProc(cell, w, cbs); break; } return ret; }