void drawClipYBut (void) { XClearArea(dsply,volumeWindow,clipYButX,clipYButY, minorAxis+blank,majorAxis+blank,False); GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf-3, (control->buttonQueue[clipYBut]).buttonY-3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf+3, (control->buttonQueue[clipYBut]).buttonY-3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf-3, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight+3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf+3, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight+3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight,Xoption); GSetForeground(trashGC,(float)monoColor(arcColor),Xoption); /* note: minimum buttons closer to the box */ GFillArc(trashGC,volumeWindow, (int)(clipYButX + minorAxis/2 - 8), (int)(yClipMinN * (majorAxis-tinyArc) + clipYButY), arcSize,arcSize,90*64,360*64,Xoption); /* 64 units per degree */ GFillArc(trashGC,volumeWindow, (int)(clipYButX + minorAxis/2 + 3), (int)(yClipMaxN * (majorAxis-tinyArc) + clipYButY), arcSize,arcSize,90*64,360*64,Xoption); /* 64 units per degree */ GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption); GDrawString(volumeGC,volumeWindow,clipYMessX,clipYMessY,"Y",1,Xoption); }
void Toolbar::reconfigure(void) { ScreenResource &resource = _screen->resource(); const ToolbarOptions &options = resource.toolbarOptions(); const ToolbarStyle &style = resource.toolbarStyle(); unsigned int width = (_screen->screenInfo().width() * options.width_percent) / 100; const unsigned int border_width = style.toolbar.borderWidth(); const unsigned int extra = style.frame_margin == 0 ? style.button.borderWidth() : 0; frame.rect.setSize(width, style.toolbar_height); int x, y; switch (options.placement) { case TopLeft: case TopRight: case TopCenter: switch (options.placement) { case TopLeft: x = 0; break; case TopRight: x = _screen->screenInfo().width() - frame.rect.width(); break; default: x = (_screen->screenInfo().width() - frame.rect.width()) / 2; break; } y = 0; frame.y_hidden = style.hidden_height - frame.rect.height(); break; case BottomLeft: case BottomRight: case BottomCenter: default: switch (options.placement) { case BottomLeft: x = 0; break; case BottomRight: x = _screen->screenInfo().width() - frame.rect.width(); break; default: x = (_screen->screenInfo().width() - frame.rect.width()) / 2; break; } y = _screen->screenInfo().height() - frame.rect.height(); frame.y_hidden = _screen->screenInfo().height() - style.hidden_height; break; } frame.rect.setPos(x, y); updateStrut(); time_t ttmp = time(NULL); unsigned int clock_w = 0u, label_w = 0u; if (ttmp != -1) { struct tm *tt = localtime(&ttmp); if (tt) { char t[1024]; int len = strftime(t, 1024, options.strftime_format.c_str(), tt); if (len == 0) { // invalid time format found // so use the default const_cast<std::string &>(options.strftime_format) = "%I:%M %p"; len = strftime(t, 1024, options.strftime_format.c_str(), tt); } /* * find the length of the rendered string and add room for two extra * characters to it. This allows for variable width output of the fonts. * two 'w' are used to get the widest possible width */ clock_w = bt::textRect(_screen->screenNumber(), style.font, bt::toUnicode(t)).width() + bt::textRect(_screen->screenNumber(), style.font, bt::toUnicode("ww")).width(); } } for (unsigned int i = 0; i < _screen->workspaceCount(); i++) { width = bt::textRect(_screen->screenNumber(), style.font, _screen->resource().workspaceName(i)).width(); label_w = std::max(label_w, width); } label_w = clock_w = std::max(label_w, clock_w) + (style.label_margin * 2); unsigned int window_label_w = (frame.rect.width() - (border_width * 2) - (clock_w + (style.button_width * 4) + label_w + (style.frame_margin * 8)) + extra*6); XMoveResizeWindow(display, frame.window, frame.rect.x(), hidden ? frame.y_hidden : frame.rect.y(), frame.rect.width(), frame.rect.height()); // workspace label frame.slabel_rect.setRect(border_width + style.frame_margin, border_width + style.frame_margin, label_w, style.label_height); // previous workspace button frame.ps_rect.setRect(border_width + (style.frame_margin * 2) + label_w - extra, border_width + style.frame_margin, style.button_width, style.button_width); // next workspace button frame.ns_rect.setRect(border_width + (style.frame_margin * 3) + label_w + style.button_width - (extra * 2), border_width + style.frame_margin, style.button_width, style.button_width); // window label frame.wlabel_rect.setRect(border_width + (style.frame_margin * 4) + (style.button_width * 2) + label_w - (extra * 3), border_width + style.frame_margin, window_label_w, style.label_height); // previous window button frame.pw_rect.setRect(border_width + (style.frame_margin * 5) + (style.button_width * 2) + label_w + window_label_w - (extra * 4), border_width + style.frame_margin, style.button_width, style.button_width); // next window button frame.nw_rect.setRect(border_width + (style.frame_margin * 6) + (style.button_width * 3) + label_w + window_label_w - (extra * 5), border_width + style.frame_margin, style.button_width, style.button_width); // clock frame.clock_rect.setRect(frame.rect.width() - clock_w - style.frame_margin - border_width, border_width + style.frame_margin, clock_w, style.label_height); XMoveResizeWindow(display, frame.workspace_label, frame.slabel_rect.x(), frame.slabel_rect.y(), frame.slabel_rect.width(), frame.slabel_rect.height()); XMoveResizeWindow(display, frame.psbutton, frame.ps_rect.x(), frame.ps_rect.y(), frame.ps_rect.width(), frame.ps_rect.height()); XMoveResizeWindow(display, frame.nsbutton, frame.ns_rect.x(), frame.ns_rect.y(), frame.ns_rect.width(), frame.ns_rect.height()); XMoveResizeWindow(display, frame.window_label, frame.wlabel_rect.x(), frame.wlabel_rect.y(), frame.wlabel_rect.width(), frame.wlabel_rect.height()); XMoveResizeWindow(display, frame.pwbutton, frame.pw_rect.x(), frame.pw_rect.y(), frame.pw_rect.width(), frame.pw_rect.height()); XMoveResizeWindow(display, frame.nwbutton, frame.nw_rect.x(), frame.nw_rect.y(), frame.nw_rect.width(), frame.nw_rect.height()); XMoveResizeWindow(display, frame.clock, frame.clock_rect.x(), frame.clock_rect.y(), frame.clock_rect.width(), frame.clock_rect.height()); frame.base = bt::PixmapCache::find(_screen->screenNumber(), style.toolbar, frame.rect.width(), frame.rect.height(), frame.base); frame.slabel = bt::PixmapCache::find(_screen->screenNumber(), style.slabel, frame.slabel_rect.width(), frame.slabel_rect.height(), frame.slabel); frame.wlabel = bt::PixmapCache::find(_screen->screenNumber(), style.wlabel, frame.wlabel_rect.width(), frame.wlabel_rect.height(), frame.wlabel); frame.clk = bt::PixmapCache::find(_screen->screenNumber(), style.clock, frame.clock_rect.width(), frame.clock_rect.height(), frame.clk); frame.button = bt::PixmapCache::find(_screen->screenNumber(), style.button, style.button_width, style.button_width, frame.button); frame.pbutton = bt::PixmapCache::find(_screen->screenNumber(), style.pressed, style.button_width, style.button_width, frame.pbutton); XClearArea(display, frame.window, 0, 0, frame.rect.width(), frame.rect.height(), True); XClearArea(display, frame.workspace_label, 0, 0, label_w, style.label_height, True); XClearArea(display, frame.window_label, 0, 0, window_label_w, style.label_height, True); XClearArea(display, frame.clock, 0, 0, clock_w, style.label_height, True); XClearArea(display, frame.psbutton, 0, 0, style.button_width, style.button_width, True); XClearArea(display, frame.nsbutton, 0, 0, style.button_width, style.button_width, True); XClearArea(display, frame.pwbutton, 0, 0, style.button_width, style.button_width, True); XClearArea(display, frame.nwbutton, 0, 0, style.button_width, style.button_width, True); }
void display_clear() { /* Insert code to clear the graphics display here */ XClearArea( display, window, 0, 0, width, height, False ); }
void DrawLineTypePattern ( Widget w, XtPointer client_data, XtPointer xt_call_data ) { int x1, x2, y, i, temp; int p_sign, scale, which; Dimension width, height; Display *dp_id; Drawable draw_id; XGCValues values; which = (int) client_data; XtVaGetValues ( w, XmNwidth, &width, XmNheight, &height, NULL ); x1 = x2 = DRAW_MARGIN; y = height/2; dp_id = XtDisplay(w); draw_id = XtWindow(w); if ( gct == NULL ) { values.line_width = 3; gct = XCreateGC(dp_id, draw_id, (unsigned long)NULL, &values); } XClearArea(dp_id, draw_id, DRAW_MARGIN/2, DRAW_MARGIN/2, width - DRAW_MARGIN, DRAW_MARGIN, False); while( x1 < width - DRAW_MARGIN) { for ( i = 0; i < 8; i++) { temp = linetypes[which-1][i]; if (temp == 0) break; p_sign = temp/abs(temp); switch (p_sign) { case 1: x2 = x1 + LSCALE*temp; if ( x2 > (width - DRAW_MARGIN) ) x2 = width - DRAW_MARGIN; if (i%2 == 0) XDrawLine(dp_id, draw_id, gct, x1, y, x2, y); break; case -1: x2 = x1 + LSCALE; if ( x2 > (width - DRAW_MARGIN) ) return; if (i%2 == 0) XDrawLine(dp_id, draw_id, gct, x1, y, x2, y ); break; } x1 = x2; } } }
static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_edittext *et; t_windata *win; KeySym keysym; char c[BUFSIZE+1], *bp; char scrbuf[STRLEN]; int i, xp, xtitle, ewidth; if (dlgitem->type != edlgET) { gmx_incons("st processing"); } et = &(dlgitem->u.edittext); win = &(dlgitem->win); /* Copy string part that is visible into screen buffer */ for (i = 0; (i < et->buflen); i++) { scrbuf[i] = et->buf[i+et->strbegin]; } scrbuf[i] = '\0'; switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, x11->fg); xtitle = XTextWidth(x11->font, win->text, strlen(win->text)); ewidth = win->width-xtitle; TextInRect(x11, win->self, win->text, 0, 0, xtitle-1, win->height, eXLeft, eYCenter); XClearArea(x11->disp, win->self, xtitle, 0, ewidth+XCARET, win->height, False); TextInRect(x11, win->self, scrbuf, xtitle+XCARET, 0, ewidth, win->height, eXLeft, eYCenter); #ifdef DEBUG printf("Expose\n"); #endif if (win->bFocus) { ShowCaret(x11, dlgitem); } break; case ButtonPress: /* Calculate new position for caret */ et->pos = strlen(et->buf); bp = strdup(et->buf); xp = event->xbutton.x-XTextWidth(x11->font, win->text, strlen(win->text))- XCARET; while ((et->pos > 0) && (XTextWidth(x11->font, bp, strlen(bp)) > xp)) { et->pos--; bp[et->pos] = '\0'; } sfree(bp); et->bChanged = TRUE; return ETCHANGED; case KeyPress: /* Check for HelpKey */ if (HelpPressed(event)) { return DefWndProc(x11, dlgitem, event); } XLookupString(&(event->xkey), c, BUFSIZE, &keysym, NULL); #ifdef DEBUG printf("Keysym: %x\n", keysym); #endif switch (keysym) { case XK_Delete: if (my_delete(et->buf, &(et->pos))) { et->bChanged = TRUE; return ETCHANGED; } else { XBell(x11->disp, 50); } break; case XK_BackSpace: if (my_backspace(et->buf, &(et->pos))) { et->bChanged = TRUE; return ETCHANGED; } else { XBell(x11->disp, 50); } break; case XK_KP_Enter: case XK_Return: return ENTERPRESSED; case XK_Home: et->pos = 0; et->strbegin = 0; et->bChanged = TRUE; return ETCHANGED; case XK_End: if (strlen(et->buf) <= et->buflen) { et->pos = strlen(et->buf); } else { et->pos = et->buflen; et->strbegin = strlen(et->buf)-et->buflen; } et->bChanged = TRUE; return ETCHANGED; case XK_Left: et->pos = max(0, et->pos-1); et->strbegin = min(et->strbegin, et->pos); et->bChanged = TRUE; return ETCHANGED; case XK_Right: if ((et->pos < et->buflen) && (et->strbegin+et->buflen > strlen(et->buf))) { et->pos++; } else if ((et->buflen < strlen(et->buf)) && (et->strbegin < strlen(et->buf)-et->buflen)) { et->strbegin++; } else { break; } et->bChanged = TRUE; return ETCHANGED; default: if (keysym < 256) { if (insert(et->buf, c[0], &(et->pos))) { et->bChanged = TRUE; return ETCHANGED; } } XBell(x11->disp, 50); break; } break; case LeaveNotify: win->bFocus = FALSE; HideCaret(x11, dlgitem); if (et->bChanged) { et->bChanged = FALSE; } break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
void updateScreenClipped( int x, int y, int w, int h ) { XClearArea(dp, wi, x, y, w, h, 0); XSync( dp, 0 ); }
static void show_link(TextNode *node) { /* XFontStruct *old_font;*/ XWindowChanges wc; /*int twidth, boxwidth, old_color;*/ int active; switch (node->type) { case Upbutton: if (!need_up_button) { XClearArea(gXDisplay, gWindow->fDisplayedWindow, node->x, node->y - node->height + gRegionOffset, node->width, node->height, 0); active = 0; } else active = 1; break; case Returnbutton: if (!need_return_button) { XClearArea(gXDisplay, gWindow->fDisplayedWindow, node->x, node->y - node->height + gRegionOffset, node->width, node->height, 0); active = 0; } else active = 1; break; case Helpbutton: if (!need_help_button) { XClearArea(gXDisplay, gWindow->fDisplayedWindow, node->x, node->y - node->height + gRegionOffset, node->width, node->height, 0); active = 0; } else active = 1; break; default: active = 1; break; } if (active) { ButtonList *bl = alloc_button_list(); push_active_group(); wc.x = node->x; wc.y = node->y - node->height + y_off + gRegionOffset; wc.height = node->height; wc.width = node->width - trailing_space(node->next); bl->x0 = wc.x; bl->y0 = wc.y; bl->x1 = bl->x0 + wc.width; bl->y1 = bl->y0 + wc.height; bl->link = node->link; if (!not_in_scroll) { bl->y0 += gWindow->page->top_scroll_margin + scroll_top_margin; bl->y1 += gWindow->page->top_scroll_margin + scroll_top_margin; bl->next = gWindow->page->s_button_list; gWindow->page->s_button_list = bl; } else { bl->next = gWindow->page->button_list; gWindow->page->button_list = bl; } } else rm_top_group(); }
/* * Function: * PaintCommandWidget * Parameters: * w - command widget * region - region to paint (passed to the superclass) * change - did it change either set or highlight state? */ static void PaintCommandWidget(Widget w, XEvent *event, Region region, Bool change) { CommandWidget cbw = (CommandWidget)w; Bool very_thick; GC norm_gc, rev_gc; very_thick = cbw->command.highlight_thickness > Min(XtWidth(cbw), XtHeight(cbw)) / 2; if (cbw->command.highlight_thickness == 0) { (*SuperClass->core_class.expose) (w, event, region); return; } /* * If we are set then use the same colors as if we are not highlighted */ if (cbw->command.highlighted != HighlightNone) { norm_gc = cbw->command.inverse_GC; rev_gc = cbw->command.normal_GC; } else { norm_gc = cbw->command.normal_GC; rev_gc = cbw->command.inverse_GC; } if (!((!change && cbw->command.highlighted == HighlightNone) || (cbw->command.highlighted == HighlightWhenUnset && cbw->command.set))) { if (very_thick) XFillRectangle(XtDisplay(w),XtWindow(w), rev_gc, 0, 0, XtWidth(cbw), XtHeight(cbw)); else { /* wide lines are centered on the path, so indent it */ if (cbw->core.background_pixmap != XtUnspecifiedPixmap && rev_gc == cbw->command.inverse_GC) { XClearArea(XtDisplay(w), XtWindow(w), 0, 0, XtWidth(cbw), cbw->command.highlight_thickness, False); XClearArea(XtDisplay(w), XtWindow(w), 0, cbw->command.highlight_thickness, cbw->command.highlight_thickness, XtHeight(cbw) - (cbw->command.highlight_thickness<<1), False); XClearArea(XtDisplay(w), XtWindow(w), XtWidth(cbw) - cbw->command.highlight_thickness, cbw->command.highlight_thickness, cbw->command.highlight_thickness, XtHeight(cbw) - (cbw->command.highlight_thickness<<1), False); XClearArea(XtDisplay(w), XtWindow(w), 0, XtHeight(cbw) - cbw->command.highlight_thickness, XtWidth(cbw), cbw->command.highlight_thickness, False); } else { int offset = cbw->command.highlight_thickness / 2; XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset, XtWidth(cbw) - cbw->command.highlight_thickness, XtHeight(cbw) - cbw->command.highlight_thickness); } } } (*SuperClass->core_class.expose)(w, event, region); }
void DrawTextField(struct XObj *xobj, XEvent *evp) { int x1,y1; int x2,l; int nl=0; int right=0; int offset,offset2,offset3; int end_value; fprintf(stderr,"DrawTextField: value %d value2 %d value3 %d\n", xobj->value, xobj->value2, xobj->value3); y1 = xobj->Ffont->ascent; l=strlen(xobj->title); /* calculate byte offsets corresponding to value,value2,value3 */ offset = getByteOffsetBoundsCheck(xobj->Ffont,xobj->title,xobj->value); offset2 = getByteOffsetBoundsCheck(xobj->Ffont,xobj->title, xobj->value2); offset3 = getByteOffsetBoundsCheck(xobj->Ffont,xobj->title, xobj->value3); /* value corresponding to behind last character */ end_value = FlocaleStringCharLength(xobj->Ffont, xobj->title ); if(offset == l) xobj->value = end_value; if(offset2 == l) xobj->value2 = end_value; if(offset3 == l) xobj->value3 = end_value; fprintf(stderr, "DrawTextField: offset: %d offset2 %d, offset3: %d\n", offset, offset2, offset3); /*if (offset > l) xobj->value = FlocaleStringByteToCharOffset(xobj->Ffont, xobj->title, l-1) + 1; if (offset2 > l) xobj->value2 = FlocaleStringByteToCharOffset(xobj->Ffont, xobj->title, l-1) + 1; */ DrawReliefRect(0,0,xobj->width,xobj->height,xobj,shad,hili); XClearArea(dpy,xobj->win,2,2,xobj->width-4,xobj->height-4,False); XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]); /* calcul du premier caractere visible */ /* computation of the first visible character */ while (l-nl >= 1 && FlocaleTextWidth(xobj->Ffont,xobj->title + nl, offset - nl) > (xobj->width-10)) { nl += FlocaleStringNumberOfBytes(xobj->Ffont,xobj->title + nl); fprintf(stderr,"nl: %d\n", nl); } /* now nl is the byte offset of the first the first visible character */ if (nl > offset3) /* the first visible character needs to be updated */ { xobj->value3 = getCharOffsetBoundsCheck(xobj->Ffont, xobj->title, nl); /*FlocaleStringByteToCharOffset(xobj->Ffont, xobj->title, nl);*/ offset3 = nl; } else if (xobj->value3 > xobj->value) { xobj->value3--; offset3 = FlocaleStringCharToByteOffset(xobj->Ffont, xobj->title, xobj->value3); } fprintf(stderr, "Got visible offset; %d char %d\n", offset3, xobj->value3); /* calcul de la longueur du titre visible */ /* computation of the length of the visible title */ /* increase string until it won't fit anymore into into the textbox */ right = offset3; while(right < l && FlocaleTextWidth(xobj->Ffont, xobj->title + offset3, right - offset3) <= xobj->width - 10) { right += FlocaleStringNumberOfBytes(xobj->Ffont, xobj->title + right); } /* the string didn't fit? */ if(FlocaleTextWidth(xobj->Ffont, xobj->title + offset3, right - offset3) > xobj->width - 10) { right -= FlocaleStringNumberOfBytes( xobj->Ffont, xobj->title + FlocaleStringCharToByteOffset( xobj->Ffont, xobj->title, FlocaleStringByteToCharOffset( xobj->Ffont, xobj->title, right) - 1)); } /* unless we had an empty string, we would have already been at the beginning */ if(right < offset3) right = offset3; /*while ( l - offset3 - right >= 1 && FlocaleTextWidth(xobj->Ffont,xobj->title + offset3, l - offset3 - right) > (xobj->width-10)) { right += FlocaleStringNumberOfBytes(xobj->Ffont, xobj->title + right); fprintf(stderr, "sl: %d\n", l - offset3 - right); } */ fprintf(stderr,"computed length of visible string\n"); FwinString->win = xobj->win; FwinString->gc = xobj->gc; FwinString->x = 5; FwinString->y = y1+5; FwinString->str = xobj->title + offset3; FwinString->len = right - offset3; /*strlen(xobj->title) - offset3 - right;*/ FlocaleDrawString(dpy, xobj->Ffont, FwinString, FWS_HAVE_LENGTH); #if 0 XmbDrawString(dpy,xobj->win,xobj->xfontset,xobj->gc,5,y1+5, xobj->title + xobj->value3, strlen(xobj->title) - xobj->value3-right); #endif /* Dessin de la zone selectionnee */ /* selected zone drawing */ XSetFunction(dpy,xobj->gc,GXinvert); if (xobj->value2>xobj->value) /* Curseur avant la souris */ { x1=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset3], offset - offset3); x2=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset], offset2 - offset); } else /* Curseur apres la souris / cursor after the mouse */ { x1=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset3], offset2 - offset3); x2=FlocaleTextWidth(xobj->Ffont,&xobj->title[offset2], offset - offset2); } XFillRectangle( dpy,xobj->win,xobj->gc,x1+5,7,x2,y1+xobj->Ffont->descent-2); XSetFunction(dpy,xobj->gc,GXcopy); /* Dessin du point d'insertion */ /* insertion point drawing */ DrawPointTxt(xobj,xobj->TabColor[fore]); }
void clear_all(Display *display, Window window, GC refresh_gc) { XClearArea(display, window, 0, 0, MAX_WIDTH, MAX_HEIGHT, 1); XFillRectangle(display, back_buffer, refresh_gc, 0, 0, MAX_WIDTH, MAX_HEIGHT); }
static void UnmanageChildren( WidgetList children, Cardinal num_children, Widget parent, Cardinal* num_unique_children, Boolean call_change_managed, String caller_func) { Widget child; Cardinal i; XtWidgetProc change_managed = NULL; Bool parent_realized = False; *num_unique_children = 0; if (XtIsComposite((Widget) parent)) { LOCK_PROCESS; change_managed = ((CompositeWidgetClass) parent->core.widget_class) ->composite_class.change_managed; UNLOCK_PROCESS; parent_realized = XtIsRealized((Widget)parent); } else { XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent), "invalidParent",caller_func, XtCXtToolkitError, "Attempt to unmanage a child when parent is not Composite", (String *) NULL, (Cardinal *) NULL); } for (i = 0; i < num_children; i++) { child = children[i]; if (child == NULL) { XtAppWarningMsg(XtWidgetToApplicationContext(parent), XtNinvalidChild,caller_func,XtCXtToolkitError, "Null child passed to XtUnmanageChildren", (String *)NULL, (Cardinal *)NULL); return; } if (child->core.parent != parent) { XtAppWarningMsg(XtWidgetToApplicationContext(parent), "ambiguousParent",caller_func,XtCXtToolkitError, "Not all children have same parent in UnmanageChildren", (String *)NULL, (Cardinal *)NULL); } else if (child->core.managed) { (*num_unique_children)++; CALLGEOTAT(_XtGeoTrace(child,"Child \"%s\" is marked unmanaged\n", XtName(child))); child->core.managed = FALSE; if (XtIsWidget(child) && XtIsRealized(child) && child->core.mapped_when_managed) XtUnmapWidget(child); else { /* RectObj child */ Widget pw = child->core.parent; RectObj r = (RectObj) child; while ((pw!=NULL) && (!XtIsWidget(pw))) pw = pw->core.parent; if ((pw!=NULL) && XtIsRealized (pw)) XClearArea (XtDisplay (pw), XtWindow (pw), r->rectangle.x, r->rectangle.y, r->rectangle.width + (r->rectangle.border_width << 1), r->rectangle.height + (r->rectangle.border_width << 1), TRUE); } } } if (call_change_managed && *num_unique_children != 0 && change_managed != NULL && parent_realized) { CALLGEOTAT(_XtGeoTrace((Widget)parent, "Call parent: \"%s\"[%d,%d]'s changemanaged proc\n", XtName((Widget)parent), parent->core.width,parent->core.height)); (*change_managed) (parent); } } /* UnmanageChildren */
/* Draws a 3D rectangle */ void Draw3dRect( Window wn, int x, int y, int w, int h, XRectangle *bounding, int state, Bool iconified) { colorset_t *cset = &Colorset[0]; /* initialize to avoid warning */ int d = 1; XRectangle r,inter; Bool draw; if (ThreeDfvwm) { d = 2; } if (bounding) { r.x = bounding->x; r.y = bounding->y; r.width = bounding->width; r.height = bounding->height; } else { r.x = x; r.y = y; r.width = w; r.height = h; } XClearArea (dpy, wn, r.x, r.y, r.width, r.height, False); if (iconified) { draw = frect_get_intersection( x + d, y + d, w - 3, h - 3, r.x, r.y, r.width, r.height, &inter); if (iconcolorset >= 0) { cset = &Colorset[iconcolorset]; } if (iconcolorset >= 0 && (cset->pixmap || cset->shape_mask) && draw) { /* we have a colorset background */ SetClippedRectangleBackground( dpy, win, x + d, y + d, w - 3, h - 3, &inter, cset, Pdepth, icongraph); } else if (draw) { XFillRectangle ( dpy, wn, iconbackgraph, inter.x, inter.y, inter.width, inter.height); } XDrawLine (dpy, wn, iconhilite, x, y, x+w-2, y); XDrawLine (dpy, wn, iconhilite, x, y, x, y+h-2); if (ThreeDfvwm) { XDrawLine (dpy, wn, iconhilite, x, y+1, x+w-2, y+1); XDrawLine (dpy, wn, iconhilite, x+1, y, x+1, y+h-2); } XDrawLine (dpy, wn, iconshadow, x+1, y+h-2, x+w-2, y+h-2); XDrawLine (dpy, wn, iconshadow, x+w-2, y+h-2, x+w-2, y+1); XDrawLine (dpy, wn, blackgc, x, y+h-1, x+w-1, y+h-1); XDrawLine (dpy, wn, blackgc, x+w-1, y+h-1, x+w-1, y); return; } switch (state) { case BUTTON_UP: XDrawLine (dpy, wn, hilite, x, y, x+w-2, y); XDrawLine (dpy, wn, hilite, x, y, x, y+h-2); if (ThreeDfvwm) { XDrawLine (dpy, wn, hilite, x, y+1, x+w-2, y+1); XDrawLine (dpy, wn, hilite, x+1, y, x+1, y+h-2); } XDrawLine (dpy, wn, shadow, x+1, y+h-2, x+w-2, y+h-2); XDrawLine (dpy, wn, shadow, x+w-2, y+h-2, x+w-2, y+1); XDrawLine (dpy, wn, blackgc, x, y+h-1, x+w-1, y+h-1); XDrawLine (dpy, wn, blackgc, x+w-1, y+h-1, x+w-1, y); break; case BUTTON_BRIGHT: draw = frect_get_intersection( x + 2, y + 2, w - 4 + (2 - d), h - 4 + (2 - d), r.x, r.y, r.width, r.height, &inter); if (focuscolorset >= 0) cset = &Colorset[focuscolorset]; if (focuscolorset >= 0 && (cset->pixmap || cset->shape_mask) && draw) { /* we have a colorset background */ SetClippedRectangleBackground( dpy, win, x + 2, y + 2, w - 4 + (2 - d), h - 4 + (2 - d), &inter, cset, Pdepth, focusgraph); } else if (draw) { XFillRectangle ( dpy, wn, focusbackgraph, inter.x, inter.y, inter.width, inter.height); } if (!NoBrightFocus) XFillRectangle ( dpy, wn, checkered, inter.x, inter.y, inter.width, inter.height); XDrawLine (dpy, wn, blackgc, x, y, x+w-2, y); XDrawLine (dpy, wn, blackgc, x, y, x, y+h-2); XDrawLine (dpy, wn, focusshadow, x, y+1, x+w-2, y+1); XDrawLine (dpy, wn, focusshadow, x+1, y, x+1, y+h-2); if (ThreeDfvwm) { XDrawLine ( dpy, wn, focushilite, x+1, y+h-2, x+w-2, y+h-2); XDrawLine ( dpy, wn, focushilite, x+w-2, y+h-2, x+w-2, y+1); } XDrawLine (dpy, wn, focushilite, x, y+h-1, x+w-1, y+h-1); XDrawLine (dpy, wn, focushilite, x+w-1, y+h-1, x+w-1, y); break; case BUTTON_DOWN: XDrawLine (dpy, wn, blackgc, x, y, x+w-2, y); XDrawLine (dpy, wn, blackgc, x, y, x, y+h-2); XDrawLine (dpy, wn, shadow, x, y+1, x+w-2, y+1); XDrawLine (dpy, wn, shadow, x+1, y, x+1, y+h-2); if (ThreeDfvwm) { XDrawLine (dpy, wn, hilite, x+1, y+h-2, x+w-2, y+h-2); XDrawLine (dpy, wn, hilite, x+w-2, y+h-2, x+w-2, y+1); } XDrawLine (dpy, wn, hilite, x, y+h-1, x+w-1, y+h-1); XDrawLine (dpy, wn, hilite, x+w-1, y+h-1, x+w-1, y); break; } }
int drawBMP(char *filename, int scroll_type) { struct pic_info pic_info; XImage *image; Visual *visual; Pixmap pixmap; int depth; int i; int j; if (parse_bmp(filename, &pic_info) < 0) { exit(-1); } XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0); depth = DefaultDepth(g_disp, DefaultScreen(g_disp)); visual = DefaultVisual(g_disp, DefaultScreen(g_disp)); // create empty pixmap pixmap = XCreatePixmap(g_disp, g_win, pic_info.width, pic_info.height, depth); // create an image from pixel data image = XCreateImage(g_disp, visual, depth, ZPixmap, 0, pic_info.pixel_data, pic_info.width, pic_info.height, 32, 0); if (pic_info.height <= g_winHeight) { // image is too small to scroll XFlush(g_disp); XPutImage(g_disp, g_win, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height); XFlush(g_disp); return 0; } // copy image to pixelmap XPutImage(g_disp, pixmap, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height); if (scroll_type == SCROLL_JUMP) { if (pic_info.height <= g_winHeight) { // image too small - no scrolling required XFlush(g_disp); XCopyArea(g_disp, // connection to X server pixmap, // source drawable g_win, // dest drawable g_gc, // graphics context 0, 0, // source x,y pic_info.width, // width pic_info.height, // height 0, 0); // dest x,y XFlush(g_disp); return 0; } j = pic_info.height / g_winHeight; if (pic_info.height % g_winHeight != 0) { // need to include the last part of the image j++; } XFlush(g_disp); for (i = 0; i < j; i++) { XCopyArea(g_disp, // connection to X server pixmap, // source drawable g_win, // dest drawable g_gc, // graphics context 0, i * g_winHeight, // source x,y pic_info.width, // width pic_info.height, // height 0, 0); // dest x,y XFlush(g_disp); sleep(3); } } /* ** smooth scroll the image */ // number of lines to be scrolled j = pic_info.height - g_winHeight; if (scroll_type == SCROLL_SMOOTH1) { printf("running SCROLL_SMOOTH1\n"); XFlush(g_disp); XPutImage(g_disp, g_win, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height); XFlush(g_disp); usleep(10000); for (i = 0; i < j; i++) { XCopyArea(g_disp, g_win, g_win, g_gc, 0, 1, g_winWidth, g_winHeight - 1, 0, 0); XPutImage(g_disp, g_win, g_gc, image, 0, g_winHeight + i, 0, g_winHeight -1 , pic_info.width, 1); XFlush(g_disp); usleep(10000); } return 0; } if (scroll_type == SCROLL_SMOOTH2) { printf("running SCROLL_SMOOTH2\n"); XFlush(g_disp); for (i = 0; i < j; i++) { XPutImage(g_disp, g_win, g_gc, image, 0, i, 0, 0, pic_info.width, pic_info.height - i); XFlush(g_disp); usleep(10000); } } if (scroll_type == SCROLL_SMOOTH3) { printf("running SCROLL_SMOOTH3\n"); XFlush(g_disp); XCopyArea(g_disp, pixmap, g_win, g_gc, 0, 0, pic_info.width, pic_info.height, 0, 0); XFlush(g_disp); usleep(10000); for (i = 0; i < j; i++) { XCopyArea(g_disp, g_win, g_win, g_gc, 0, 1, g_winWidth, g_winHeight - 1, 0, 0); XCopyArea(g_disp, pixmap, g_win, g_gc, 0, g_winHeight + i, pic_info.width, 1, 0, g_winHeight -1); XFlush(g_disp); usleep(10000); } return 0; } if (scroll_type == SCROLL_SMOOTH4) { printf("running SCROLL_SMOOTH4\n"); XFlush(g_disp); for (i = 0; i < j; i++) { XCopyArea(g_disp, pixmap, g_win, g_gc, 0, i, pic_info.width, pic_info.height - i, 0, 0); XFlush(g_disp); usleep(10000); } } return 0; }
bool _pl_y_end_page (S___(Plotter *_plotter)) { plColorRecord *cptr; plXFontRecord *fptr; Pixmap bg_pixmap = (Pixmap)0; int window_width, window_height; pid_t forkval; /* compute rectangle size; note flipped-y convention */ window_width = (_plotter->data->imax - _plotter->data->imin) + 1; window_height = (_plotter->data->jmin - _plotter->data->jmax) + 1; /* if either sort of server-supported double buffering is being used, create background pixmap for Label widget (it doesn't yet have one) */ if (_plotter->x_double_buffering == X_DBL_BUF_MBX || _plotter->x_double_buffering == X_DBL_BUF_DBE) { int screen; /* screen number */ Screen *screen_struct; /* screen structure */ screen = DefaultScreen (_plotter->x_dpy); screen_struct = ScreenOfDisplay (_plotter->x_dpy, screen); bg_pixmap = XCreatePixmap(_plotter->x_dpy, _plotter->x_drawable2, (unsigned int)window_width, (unsigned int)window_height, (unsigned int)PlanesOfScreen(screen_struct)); /* copy from off-screen graphics buffer to pixmap */ XCopyArea (_plotter->x_dpy, _plotter->x_drawable3, bg_pixmap, _plotter->drawstate->x_gc_bg, 0, 0, (unsigned int)window_width, (unsigned int)window_height, 0, 0); /* pixmap is installed below as background pixmap for Label widget */ } /* If double buffering, must make final frame of graphics visible, by copying it from our off-screen graphics buffer `x_drawable3' to window. There are several types of double buffering: the two server-supported types, and the `by hand' type. */ #ifdef HAVE_X11_EXTENSIONS_XDBE_H #ifdef HAVE_DBE_SUPPORT if (_plotter->x_double_buffering == X_DBL_BUF_DBE) /* we're using the X double buffering extension; off-screen graphics buffer `x_drawable3' is a back buffer */ { XdbeSwapInfo info; /* make final frame of graphics visible by interchanging front and back buffers one last time */ info.swap_window = _plotter->x_drawable2; info.swap_action = XdbeUndefined; XdbeSwapBuffers (_plotter->x_dpy, &info, 1); /* free the back buffer */ XdbeDeallocateBackBufferName (_plotter->x_dpy, _plotter->x_drawable3); } #endif /* HAVE_DBE_SUPPORT */ #endif /* HAVE_X11_EXTENSIONS_XDBE_H */ #ifdef HAVE_X11_EXTENSIONS_MULTIBUF_H #ifdef HAVE_MBX_SUPPORT if (_plotter->x_double_buffering == X_DBL_BUF_MBX) /* we're using the X multibuffering extension; off-screen graphics buffer `x_drawable3' is a non-displayed multibuffer */ { /* make final frame of graphics visible by making the multibuffer into which we're currently drawing the on-screen multibuffer */ XmbufDisplayBuffers (_plotter->x_dpy, 1, &(_plotter->x_drawable3), 0, 0); } #endif /* HAVE_MBX_SUPPORT */ #endif /* HAVE_X11_EXTENSIONS_MULTIBUF_H */ /* if either sort of server-supported double buffering is being used, install the above-created pixmap as background pixmap for the Label widget to use, once the window has been spun off */ if (_plotter->x_double_buffering == X_DBL_BUF_MBX || _plotter->x_double_buffering == X_DBL_BUF_DBE) { Arg wargs[2]; /* werewolves */ /* install pixmap as Label widget's background pixmap */ #ifdef USE_MOTIF XtSetArg (wargs[0], XmNlabelPixmap, (Pixmap)bg_pixmap); XtSetArg (wargs[1], XmNlabelType, XmPIXMAP); XtSetValues (_plotter->y_canvas, wargs, (Cardinal)2); #else XtSetArg (wargs[0], XtNbitmap, (Pixmap)bg_pixmap); XtSetValues (_plotter->y_canvas, wargs, (Cardinal)1); #endif } if (_plotter->x_double_buffering == X_DBL_BUF_BY_HAND) /* we're double buffering _manually_, rather than using either X11 protocol extension, so our off-screen graphics buffer `x_drawable3' is an ordinary pixmap */ { /* make final frame of graphics visible by copying from pixmap to window */ XCopyArea (_plotter->x_dpy, _plotter->x_drawable3, _plotter->x_drawable2, _plotter->drawstate->x_gc_bg, 0, 0, (unsigned int)window_width, (unsigned int)window_height, 0, 0); } /* Finally: if we're not double buffering at all, we copy our off-screen graphics buffer to the window. The off-screen graphics buffer is just the Label widget's background pixmap, `x_drawable1'. */ if (_plotter->x_double_buffering == X_DBL_BUF_NONE) XCopyArea (_plotter->x_dpy, _plotter->x_drawable1, _plotter->x_drawable2, _plotter->drawstate->x_gc_bg, 0, 0, (unsigned int)window_width, (unsigned int)window_height, 0, 0); /* following two deallocations (of font records and color cell records) arrange things so that when drawing the next page of graphics, which will require another connection to the X server, the Plotter will start with a clean slate */ /* Free font records from Plotter's cache list. This involves deallocating the font name and also the XFontStruct contained in each record, if non-NULL. (NULL indicates that the font could not be retrieved.) */ fptr = _plotter->x_fontlist; _plotter->x_fontlist = NULL; while (fptr) { plXFontRecord *fptrnext; fptrnext = fptr->next; free (fptr->x_font_name); if (fptr->x_font_struct) XFreeFont (_plotter->x_dpy, fptr->x_font_struct); free (fptr); fptr = fptrnext; } /* Free cached color cells from Plotter's cache list. Do _not_ ask the server to deallocate the cells themselves, because the child process will need them; just free local storage. */ cptr = _plotter->x_colorlist; _plotter->x_colorlist = NULL; while (cptr) { plColorRecord *cptrnext; cptrnext = cptr->next; free (cptr); cptr = cptrnext; } /* A bit of last-minute cleanup (could be done elsewhere): call waitpid() to reclaim resources used by zombie child processes resulting from previous closepl()'s, if any. If this isn't done, the controlling process of any previously popped-up window won't fully exit (e.g. when `q' is typed in the window): it'll remain in the process table as a zombie until the parent process executes. */ #ifdef HAVE_WAITPID #ifdef HAVE_SYS_WAIT_H #ifdef WNOHANG { int i; /* iterate over all previously forked-off children (should really keep track of which have exited, since once a child has exited, invoking waitpid() on it is pointless) */ for (i = 0; i < _plotter->y_num_pids; i++) waitpid (_plotter->y_pids[i], (int *)NULL, WNOHANG); } #endif #endif #endif /* maybe flush X output buffer and handle X events (a no-op for XDrawablePlotters, which is overridden for XPlotters) */ _maybe_handle_x_events (S___(_plotter)); /* flush out the X output buffer; wait till all requests have been received and processed by server (see x_flushpl.c) */ _pl_x_flush_output (S___(_plotter)); /* flush output streams for all Plotters before forking */ _pl_g_flush_plotter_outstreams (S___(_plotter)); /* DO IT, MAN! */ forkval = fork (); if ((int)forkval > 0 /* fork succeeded, and we're the parent */ || (int)forkval < 0) /* fork failed */ { bool retval = true; if ((int)forkval < 0) _plotter->error (R___(_plotter) "the process could not be forked"); /* Close connection to X display associated with window that the child process should manage, i.e. with the last openpl() invoked on this Plotter. */ if (close (ConnectionNumber (_plotter->x_dpy)) < 0 && errno != EINTR) /* emphatically shouldn't happen */ { _plotter->error (R___(_plotter) "the connection to the X display could not be closed"); retval = false; } if ((int)forkval > 0) /* there's a child process, so save its pid */ { if (_plotter->y_num_pids == 0) _plotter->y_pids = (pid_t *)_pl_xmalloc (sizeof (pid_t)); else _plotter->y_pids = (pid_t *)_pl_xrealloc (_plotter->y_pids, ((_plotter->y_num_pids + 1) * sizeof (pid_t))); _plotter->y_pids[_plotter->y_num_pids] = forkval; _plotter->y_num_pids++; } /* do teardown of X-specific elements of the first drawing state on the drawing state stack */ _pl_x_delete_gcs_from_first_drawing_state (S___(_plotter)); return retval; } else /* forkval = 0; fork succeeded, and we're the child */ { bool need_redisplay = false; int i; /* Alter canvas widget's translation table, so that exit will occur when `q' is typed (or mouse is clicked). See y_openpl.c. */ _pl_y_set_data_for_quitting (S___(_plotter)); /* Close all connections to X display other than our own, i.e., close all connections that other XPlotters may have been using. No need to lock the global variables _xplotters and _xplotters_len; since we've forked and we're the child process, we're the only thread left. :-) We'll never be accessing those variables again (the only way we could would be if we were to call _maybe_handle_x_events(), and we aren't going to do that). So we don't need to worry that they may actually be locked. I.e. there was no need for us to register a handler to unlock them immediately after forking, by invoking pthread_atfork(). Which is why we didn't do that. */ for (i = 0; i < _xplotters_len; i++) if (_xplotters[i] != NULL && _xplotters[i] != _plotter && _xplotters[i]->data->opened && _xplotters[i]->data->open && close (ConnectionNumber (_xplotters[i]->x_dpy)) < 0 && errno != EINTR) /* shouldn't happen */ _plotter->error (R___(_plotter) "the connection to the X display could not be closed"); /* Repaint by sending an expose event to ourselves, copying the Label widget's background pixmap into its window. This is a good idea because the window could have been resized during the openpl..closepl. We don't do this if not double buffering (and presumably animating), unless the window size has changed since openpl was invoked (repainting makes the window flash, possibly irritating users). */ if (_plotter->x_double_buffering != X_DBL_BUF_NONE) need_redisplay = true; else { Arg wargs[2]; /* werewolves */ Dimension our_window_height, our_window_width; #ifdef USE_MOTIF XtSetArg (wargs[0], XmNwidth, &our_window_width); XtSetArg (wargs[1], XmNheight, &our_window_height); #else XtSetArg (wargs[0], XtNwidth, &our_window_width); XtSetArg (wargs[1], XtNheight, &our_window_height); #endif XtGetValues (_plotter->y_canvas, wargs, (Cardinal)2); if ((_plotter->data->imax + 1 != (int)our_window_width) || (_plotter->data->jmin + 1 != (int)our_window_height)) /* window changed size */ need_redisplay = true; } /* turn off backing store (if used); when we send the expose event to ourselves we want to repaint from the background pixmap, NOT from the server's backing store */ { XSetWindowAttributes attributes; unsigned long value_mask; attributes.backing_store = NotUseful; value_mask = CWBackingStore; XChangeWindowAttributes (_plotter->x_dpy, (Window)_plotter->x_drawable2, value_mask, &attributes); } if (need_redisplay) /* send expose event to ourselves */ XClearArea (_plotter->x_dpy, (Window)_plotter->x_drawable2, 0, 0, (unsigned int)0, (unsigned int)0, True); _plotter->data->open = false; /* flag Plotter as closed (is this useful, or just pedantic?) */ /* Manage the window. We won't get any events associated with other windows i.e. with previous invocations of openpl..closepl on this Plotter, or with other Plotters, since there's a distinct application context for every openpl..closepl. */ XtAppMainLoop (_plotter->y_app_con); /* shouldn't return */ /* NOTREACHED */ exit (EXIT_FAILURE); } }
/* EXTPROTO */ int rxvt_scrollbar_show_next(rxvt_t *r, int update, int last_top, int last_bot, int scroller_len) { int height; Drawable s; int page = ATAB(r); height = r->scrollBar.end + NEXT_SB_TBTN_HEIGHT + NEXT_SB_PAD; if (PVTS(r, page)->nscrolled == 0 || !update) { XClearArea (r->Xdisplay, r->scrollBar.win, 0, 0, SB_WIDTH_NEXT + 1, height, False); CHOOSE_GC_FG(r, r->scrollBar.next_fg); XDrawRectangle(r->Xdisplay, r->scrollBar.win, r->scrollBar.gc, 0, NEXT_SB_BD_WIDTH, SB_WIDTH_NEXT, height + NEXT_SB_BD_WIDTH); # ifdef TRANSPARENT /* set background color when there's no transparent */ if (!((r->Options & Opt_transparent) && (r->Options & Opt_transparent_scrollbar))) # endif #ifdef BACKGROUND_IMAGE /* set background color when there's no bg image */ if (None == r->scrollBar.pixmap) #endif XFillRectangle(r->Xdisplay, r->scrollBar.win, TILEGC, NEXT_SB_LPAD, 0, NEXT_SB_BTN_WIDTH, height); } if (PVTS(r, page)->nscrolled) { if (last_top < r->scrollBar.top || !update) { /* ** Area above the scroller */ # ifdef TRANSPARENT /* clear background when there's transparent */ if ((r->Options & Opt_transparent) && (r->Options & Opt_transparent_scrollbar)) XClearArea (r->Xdisplay, r->scrollBar.win, NEXT_SB_LPAD, NEXT_SB_PAD + last_top, NEXT_SB_BTN_WIDTH, r->scrollBar.top - last_top, False); else # endif # ifdef BACKGROUND_IMAGE /* clear background when there's bg image */ if (None != r->scrollBar.pixmap) XClearArea (r->Xdisplay, r->scrollBar.win, NEXT_SB_LPAD, NEXT_SB_PAD + last_top, NEXT_SB_BTN_WIDTH, r->scrollBar.top - last_top, False); else # endif XFillRectangle(r->Xdisplay, r->scrollBar.win, TILEGC, NEXT_SB_LPAD, NEXT_SB_PAD + last_top, NEXT_SB_BTN_WIDTH, r->scrollBar.top - last_top); } if (r->scrollBar.bot < last_bot || !update) { /* ** Area above the buttons but below the scroller */ # ifdef TRANSPARENT /* clear background when there's transparent */ if ((r->Options & Opt_transparent) && (r->Options & Opt_transparent_scrollbar)) XClearArea(r->Xdisplay, r->scrollBar.win, NEXT_SB_LPAD, r->scrollBar.bot + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, (last_bot - r->scrollBar.bot), False); else # endif # ifdef BACKGROUND_IMAGE /* clear background when there's bg image */ if (None != r->scrollBar.pixmap) XClearArea (r->Xdisplay, r->scrollBar.win, NEXT_SB_LPAD, r->scrollBar.bot + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, (last_bot - r->scrollBar.bot), False); else # endif XFillRectangle(r->Xdisplay, r->scrollBar.win, TILEGC, NEXT_SB_LPAD, r->scrollBar.bot + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, (last_bot - r->scrollBar.bot)); } /* ** Area of the scroller */ # ifdef TRANSPARENT /* clear background when there's transparent */ if ((r->Options & Opt_transparent) && (r->Options & Opt_transparent_scrollbar)) XClearArea (r->Xdisplay, r->scrollBar.win, NEXT_SB_LPAD, r->scrollBar.top + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, scroller_len/*-NEXT_SB_BTN_HEIGHT*/, False); else # endif # ifdef BACKGROUND_IMAGE /* clear background when there's bg image */ if (None != r->scrollBar.pixmap) XClearArea (r->Xdisplay, r->scrollBar.win, NEXT_SB_LPAD, r->scrollBar.top + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, scroller_len/*-NEXT_SB_BTN_HEIGHT*/, False); else # endif { CHOOSE_GC_FG(r, r->scrollBar.next_bg); XFillRectangle(r->Xdisplay, r->scrollBar.win, r->scrollBar.gc, NEXT_SB_LPAD, r->scrollBar.top + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, scroller_len/*-NEXT_SB_BTN_HEIGHT*/); } /* ** Here comes the dimple in the scroller */ CHOOSE_GC_FG(r, r->scrollBar.next_white); XCopyArea(r->Xdisplay, DIMPLE, r->scrollBar.win, r->scrollBar.gc, 0, 0, DIMPLE_WIDTH, DIMPLE_HEIGHT, (SB_WIDTH_NEXT - DIMPLE_WIDTH) / 2, r->scrollBar.top + NEXT_BEVEL_ULEFT_WIDTH + (scroller_len - DIMPLE_HEIGHT) / 2); /* ** Bevel around the scroller */ next_draw_bevel(r, r->scrollBar.win, NEXT_BEVEL_X, r->scrollBar.top + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH, scroller_len); /* ** Bevel around the buttons */ next_draw_bevel(r, r->scrollBar.win, NEXT_BEVEL_X, height - NEXT_SB_DBTN_HEIGHT, NEXT_SB_BTN_WIDTH, NEXT_SB_BTN_HEIGHT); next_draw_bevel(r, r->scrollBar.win, NEXT_BEVEL_X, height - NEXT_SB_SBTN_HEIGHT, NEXT_SB_BTN_WIDTH, NEXT_SB_BTN_HEIGHT); /* ** Top button */ CHOOSE_GC_FG(r, r->scrollBar.next_white); s = (scrollbar_isUp()) ? HIUPARROW : UPARROW; XCopyArea(r->Xdisplay, s, r->scrollBar.win, r->scrollBar.gc, 0, 0, ARROW_WIDTH, ARROW_HEIGHT, NEXT_BTN_FACE_X, height-NEXT_SB_DBTN_HEIGHT+NEXT_BEVEL_ULEFT_WIDTH); /* ** Bottom button */ s = (scrollbar_isDn()) ? HIDNARROW : DNARROW; XCopyArea(r->Xdisplay, s, r->scrollBar.win, r->scrollBar.gc, 0, 0, ARROW_WIDTH, ARROW_HEIGHT, NEXT_BTN_FACE_X, height-NEXT_SB_SBTN_HEIGHT+NEXT_BEVEL_ULEFT_WIDTH); } return 1; }
void inputCB (Widget w, char * clientdata, XtcwpAxesCallbackStruct *ca) { int x=ca->x,y=ca->y,width=ca->width,height=ca->height; float x1beg=ca->x1beg,x1end=ca->x1end,x2beg=ca->x2beg,x2end=ca->x2end; int style=ca->style; XEvent *event=ca->event; int xb,yb,wb,hb; float x1begn,x1endn,x2begn,x2endn; static int firstinput=1; static float x1begs,x1ends,x2begs,x2ends; /* if first input, save initial axes limits */ if (firstinput) { x1begs = x1beg; x1ends = x1end; x2begs = x2beg; x2ends = x2end; firstinput = 0; clientdata += 0; /* dummy */ } if (event->type==ButtonPress && event->xbutton.button==Button3) { /* JG: requires extra fields in Axes.c's defaultTranslations[] to make this work. Harmless if not */ exit(0); } /* track pointer and get rubber box */ XtcwpRubberBox(XtDisplay(w),XtWindow(w),*event,&xb,&yb,&wb,&hb); /* if new box has zero width or height */ if (wb==0 || hb==0) { /* restore initial limits */ XtcwpSetAxesValues(w,x1begs,x1ends,x2begs,x2ends); /* else if non-zero zoom box */ } else { /* clip box */ if (xb<x) { wb -= x-xb; xb = x; } if (yb<y) { hb -= y-yb; yb = y; } if (xb+wb>x+width) wb = x-xb+width; if (yb+hb>y+height) hb = y-yb+height; /* determine axes limits */ if (style==XtcwpNORMAL) { x1begn = x1beg+(xb-x)*(x1end-x1beg)/width; x1endn = x1beg+(xb+wb-x)*(x1end-x1beg)/width; x2begn = x2end+(yb+hb-y)*(x2beg-x2end)/height; x2endn = x2end+(yb-y)*(x2beg-x2end)/height; } else { x1endn = x1beg+(yb+hb-y)*(x1end-x1beg)/height; x1begn = x1beg+(yb-y)*(x1end-x1beg)/height; x2begn = x2beg+(xb-x)*(x2end-x2beg)/width; x2endn = x2beg+(xb+wb-x)*(x2end-x2beg)/width; } /* set axes limits */ XtcwpSetAxesValues(w,x1begn,x1endn,x2begn,x2endn); } /* force an expose event */ XClearArea(XtDisplay(w),XtWindow(w),0,0,0,0,True); }
static void DrawSlider(XmGaugeWidget gw, Boolean clear) { #define THIS gw->gauge int size, sht; float ratio; /***chubraev char string[20]; int len; unsigned long backgr,foregr; XRectangle rects[1]; ***/ sht = gw->primitive.shadow_thickness; ratio = (float)THIS.value/ (float)(THIS.maximum - THIS.minimum); /***chubraev sprintf(string,"%-d%%",(int)(ratio*100)); len=strlen(string); XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL); ***/ if(clear) { XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht, gw->core.width - 2 * sht, gw->core.height - 2 * sht, False); } switch(THIS.orientation) { case XmHORIZONTAL: size = (int) ((gw->core.width - 2 * sht)*ratio); /***chubraev XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2, gw->core.height - 2 * sht, string, len); ***/ switch(THIS.processingDirection) { case XmMAX_ON_RIGHT: case XmMAX_ON_BOTTOM: XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, sht, size, gw->core.height - 2 * sht); /***chubraev rects[0].x = sht; rects[0].y = sht; rects[0].width = size; rects[0].height = gw->core.height - 2 * sht; ***/ break; case XmMAX_ON_LEFT: case XmMAX_ON_TOP: XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, gw->core.width - size - sht, sht, size, gw->core.height - 2 * sht); /***chubraev rects[0].x = gw->core.width - size - sht; rects[0].y = sht; rects[0].width = size; rects[0].height = gw->core.height - 2 * sht; ***/ break; } /***chubraev XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted); XSetForeground(XtDisplay(gw), THIS.gc, backgr); XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2, gw->core.height - 2 * sht, string, len); ***/ break; case XmVERTICAL: size = (int) ((gw->core.height - 2 * sht)*ratio); /***chubraev XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, sht+gw->core.height/2, string,len); ***/ switch(THIS.processingDirection) { case XmMAX_ON_RIGHT: case XmMAX_ON_BOTTOM: XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, sht, gw->core.width - 2 * sht, size); /***chubraev rects[0].x = sht; rects[0].y = sht; rects[0].width = gw->core.width - 2 * sht; rects[0].height = size; ***/ break; case XmMAX_ON_LEFT: case XmMAX_ON_TOP: XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, gw->core.height - size - sht, gw->core.width - 2 * sht, size); /***chubraev rects[0].x = sht; rects[0].y = gw->core.height - size - sht; rects[0].width = gw->core.width - 2 * sht; rects[0].height = size; ***/ } /***chubraev XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted); XSetForeground(XtDisplay(gw), THIS.gc, backgr); XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, sht+gw->core.height/2, string,len); ***/ break; } /***chubraev XSetClipMask(XtDisplay(gw), THIS.gc, None); XSetForeground(XtDisplay(gw), THIS.gc, foregr); ***/ #undef THIS }
main() { Window w2; Display *dpy = XOpenDisplay(NIL); assert(dpy); Screen *scr = DefaultScreenOfDisplay(dpy); // CreateWindow Window w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XDestroyWindow(dpy, w); // CreateWindow with arguments XSetWindowAttributes swa; swa.background_pixel = WhitePixelOfScreen(scr); swa.bit_gravity = NorthWestGravity; swa.border_pixel = BlackPixelOfScreen(scr); swa.colormap = DefaultColormapOfScreen(scr); swa.cursor = None; swa.win_gravity = NorthGravity; w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixel | CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWWinGravity, &swa); // CreateWindow with other arguments XDestroyWindow(dpy, w); Pixmap pixmap = XCreatePixmap(dpy, RootWindowOfScreen(scr), 45, 25, DefaultDepthOfScreen(scr)); assert(pixmap); swa.background_pixmap = pixmap; swa.border_pixmap = pixmap; w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixmap | CWBorderPixmap, &swa); // ChangeWindowAttributes swa.backing_planes = 0x1; swa.backing_pixel = WhitePixelOfScreen(scr); swa.save_under = True; swa.event_mask = KeyPressMask | KeyReleaseMask; swa.do_not_propagate_mask = ButtonPressMask | Button4MotionMask; swa.override_redirect = False; XChangeWindowAttributes(dpy, w, CWBackingPlanes | CWBackingPixel | CWSaveUnder | CWEventMask | CWDontPropagate | CWOverrideRedirect, &swa); // GetWindowAttributes XWindowAttributes wa; Status success = XGetWindowAttributes(dpy, w, &wa); // DestroyWindow (done) // DestroySubwindows w2 = XCreateWindow(dpy, w, 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XDestroySubwindows(dpy, w); // ChangeSaveSet // Display *dpy2 = XOpenDisplay(NIL); // assert(dpy2); // XAddToSaveSet(dpy2, w); // XCloseDisplay(dpy2); // ReparentWindow w2 = XCreateWindow(dpy, RootWindowOfScreen(scr), 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XReparentWindow(dpy, w2, w, 10, 5); // MapWindow XMapWindow(dpy, w); // MapSubwindows XMapSubwindows(dpy, w); // UnmapWindow XUnmapWindow(dpy, w); // UnmapSubwindows XMapWindow(dpy, w); XUnmapSubwindows(dpy, w2); XMapSubwindows(dpy, w); // ConfigureWindow Window w3 = XCreateWindow(dpy, w, 10, 50, 100, 10, 2, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XMapWindow(dpy, w3); XWindowChanges wc; wc.x = -5; wc.y = -10; wc.width = 50; wc.height = 40; wc.border_width = 7; wc.sibling = w2; wc.stack_mode = Opposite; XConfigureWindow(dpy, w3, CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWSibling | CWStackMode, &wc); // CirculateWindow XCirculateSubwindows(dpy, w, RaiseLowest); // GetGeometry Window root; int x, y; unsigned width, height, border_width, depth; XGetGeometry(dpy, w, &root, &x, &y, &width, &height, &border_width, &depth); // QueryTree Window parent; Window *children; unsigned nchildren; success = XQueryTree(dpy, w, &root, &parent, &children, &nchildren); XFree(children); // InternAtom Atom a = XInternAtom(dpy, "WM_PROTOCOLS", True); // GetAtomName char *string = XGetAtomName(dpy, XA_PRIMARY); XFree(string); // ChangeProperty XStoreName(dpy, w, "test window"); // DeleteProperty XDeleteProperty(dpy, w, XA_WM_NAME); // GetProperty // TODO // ListProperties int num_prop; Atom *list = XListProperties(dpy, w, &num_prop); XFree(list); // SetSelectionOwner XSetSelectionOwner(dpy, XA_PRIMARY, w, 12000); XSetSelectionOwner(dpy, XA_SECONDARY, w, CurrentTime); // GetSelectionOwner Window wx = XGetSelectionOwner(dpy, XA_PRIMARY); // ConvertSelection XConvertSelection(dpy, XA_SECONDARY, XA_CURSOR, XA_POINT, w, CurrentTime); // SendEvent // GrabPointer std::cerr << "Grabbing" << std::endl; int res = XGrabPointer(dpy, w, False, Button5MotionMask | PointerMotionHintMask, GrabModeSync, GrabModeAsync, w, None, CurrentTime); XSync(dpy, False); // sleep(5); // UngrabPointer std::cerr << "Ungrabbing" << std::endl; XUngrabPointer(dpy, CurrentTime); // GrabButton XGrabButton(dpy, 3, ShiftMask | ControlMask, w, False, PointerMotionHintMask | Button2MotionMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, 2, AnyModifier, w, False, PointerMotionHintMask | Button2MotionMask, GrabModeAsync, GrabModeSync, None, None); // UngrabButton XUngrabButton(dpy, 2, LockMask, w); // ChangeActivePointerGrab XChangeActivePointerGrab(dpy, ButtonPressMask, None, CurrentTime); // GrabKeyboard XGrabKeyboard(dpy, w, True, GrabModeSync, GrabModeSync, 12000); // UngrabKeyboard XUngrabKeyboard(dpy, 13000); // GrabKey XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Tab), ShiftMask | Mod3Mask, w, True, GrabModeSync, GrabModeSync); // UngrabKey XUngrabKey(dpy, AnyKey, AnyModifier, w); // AllowEvents XAllowEvents(dpy, AsyncPointer, 14000); // GrabServer XGrabServer(dpy); // UngrabServer XUngrabServer(dpy); // QueryPointer Window child; int root_x, root_y, win_x, win_y; unsigned mask; Bool bres = XQueryPointer(dpy, w, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); // GetMotionEvents int nevents; XGetMotionEvents(dpy, w, 15000, 16000, &nevents); // TranslateCoordinates int dest_x, dest_y; XTranslateCoordinates(dpy, w, w2, 10, 20, &dest_x, &dest_y, &child); // WarpPointer XWarpPointer(dpy, w, w2, 0, 0, 100, 100, 20, 30); // SetInputFocus XSetInputFocus(dpy,w, RevertToPointerRoot, 17000); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, 17000); // GetInputFocus Window focus; int revert_to; XGetInputFocus(dpy, &focus, &revert_to); // QueryKeymap char keys_return[32]; XQueryKeymap(dpy, keys_return); // OpenFont Font fid = XLoadFont(dpy, "cursor"); // CloseFont XUnloadFont(dpy, fid); // QueryFont XFontStruct *fs = XLoadQueryFont(dpy, "cursor"); assert(fs); // QueryTextExtents int direction, font_ascent, font_descent; XCharStruct overall; XQueryTextExtents(dpy, fs -> fid, "toto", 4, &direction, &font_ascent, &font_descent, &overall); XQueryTextExtents(dpy, fs -> fid, "odd__length", 11, &direction, &font_ascent, &font_descent, &overall); XChar2b c2bs; c2bs.byte1 = '$'; c2bs.byte2 = 'B'; XQueryTextExtents16(dpy, fs -> fid, &c2bs, 1, &direction, &font_ascent, &font_descent, &overall); XQueryTextExtents(dpy, fs -> fid, longString, strlen(longString), &direction, &font_ascent, &font_descent, &overall); // ListFonts int actual_count; char **fontList = XListFonts(dpy, "*", 100, &actual_count); XFree((char *)fontList); // ListFontsWithInfo int count; XFontStruct *info; char **names = XListFontsWithInfo(dpy, "*", 100, &count, &info); XFreeFontInfo(names, info, count); // SetFontPath // GetFontPath int npaths; char **charList = XGetFontPath(dpy, &npaths); char **charList2 = new char *[npaths + 1]; memcpy(charList2, charList, npaths * sizeof(char *)); charList2[npaths] = charList2[0]; XSetFontPath(dpy, charList2, npaths + 1); XSetFontPath(dpy, charList, npaths); // Reset to some reasonnable value XFreeFontPath(charList); delete [] charList2; // CreatePixmap Pixmap pix2 = XCreatePixmap(dpy, w, 100, 200, DefaultDepthOfScreen(scr)); // FreePixmap XFreePixmap(dpy, pix2); // CreateGC Pixmap bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr), "\000\000\001\000\000\001\000\000\001\377\377\377", 3, 4); XGCValues gcv; gcv.function = GXand; gcv.plane_mask = 0x1; gcv.foreground = WhitePixelOfScreen(scr); gcv.background = BlackPixelOfScreen(scr); gcv.line_width = 2; gcv.line_style = LineDoubleDash; gcv.cap_style = CapProjecting; gcv.join_style = JoinRound; gcv.fill_style = FillStippled; gcv.fill_rule = EvenOddRule; gcv.arc_mode = ArcPieSlice; gcv.tile = pixmap; gcv.stipple = bitmap; gcv.ts_x_origin = 3; gcv.ts_y_origin = 4; gcv.font = fs -> fid; gcv.subwindow_mode = ClipByChildren; gcv.graphics_exposures = True; gcv.clip_x_origin = 5; gcv.clip_y_origin = 6; gcv.clip_mask = bitmap; gcv.dash_offset = 1; gcv.dashes = 0xc2; GC gc = XCreateGC(dpy, w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCDashOffset | GCDashList | GCArcMode, &gcv); // ChangeGC gcv.function = GXandReverse; // Only a few of these should appear, since the values are cached on the client side by the Xlib. XChangeGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, &gcv); // CopyGC GC gc2 = XCreateGC(dpy, w, 0, NIL); XCopyGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, gc2); // SetDashes XSetDashes(dpy, gc, 3, "\001\377\001", 3); // SetClipRectangles XRectangle rectangles[] = { { 10, 20, 30, 40 }, { 100, 200, 5, 3 }, { -5, 1, 12, 24 } }; XSetClipRectangles(dpy, gc, 12, 9, rectangles, SIZEOF(rectangles), Unsorted); // FreeGC // done already // ClearArea XClearArea(dpy, w, 30, 10, 10, 100, False); // CopyArea XCopyArea(dpy, w, pixmap, gc, 0, 0, 100, 100, 10, 10); // CopyPlane // This won't work if the Screen doesn't have at least 3 planes XCopyPlane(dpy, pixmap, w, gc, 20, 10, 40, 30, 0, 0, 0x4); // PolyPoint XDrawPoint(dpy, w, gc, 1, 2); XPoint points[] = { { 3, 4 }, { 5, 6 } }; XDrawPoints(dpy, w, gc, points, SIZEOF(points), CoordModeOrigin); // PolyLine XDrawLines(dpy, w, gc, points, SIZEOF(points), CoordModePrevious); // PolySegment XSegment segments[] = { { 7, 8, 9, 10 }, { 11, 12, 13, 14 }, { 15, 16, 17, 18 } }; XDrawSegments(dpy, w, gc, segments, SIZEOF(segments)); // PolyRectangle XDrawRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles)); // PolyArc XArc arcs[] = { { 10, 20, 30, 40, 50, 60 }, { -70, 80, 90, 100, 110, 120 }, { 10, 20, 30, 40, 50, -30 } }; XDrawArcs(dpy, w, gc, arcs, SIZEOF(arcs)); // FillPoly XFillPolygon(dpy, w, gc, points, SIZEOF(points), Convex, CoordModePrevious); // PolyFillRectangle XFillRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles)); // PolyFillArc XFillArcs(dpy, w, gc, arcs, SIZEOF(arcs)); // PutImage // GetImage XImage *image = XGetImage(dpy, w, 10, 20, 40, 30, AllPlanes, ZPixmap); XPutImage(dpy, w, gc, image, 0, 0, 50, 60, 40, 30); XSync(dpy, False); // Make the next request starts at the beginning of a packet // PolyText8 XTextItem textItems[3]; textItems[0].chars = "toto"; textItems[0].nchars = strlen(textItems[0].chars); textItems[0].delta = -3; textItems[0].font = fs->fid; textItems[1].chars = "titi"; textItems[1].nchars = strlen(textItems[1].chars); textItems[1].delta = 3; textItems[1].font = None; textItems[2].chars = "tutu"; textItems[2].nchars = strlen(textItems[2].chars); textItems[2].delta = 0; textItems[2].font = fs->fid; XDrawText(dpy, w, gc, 10, 10, textItems, 3); XTextItem textItems2[3]; textItems2[0].chars = "totox"; textItems2[0].nchars = strlen(textItems2[0].chars); textItems2[0].delta = -3; textItems2[0].font = fs->fid; textItems2[1].chars = "titi"; textItems2[1].nchars = strlen(textItems2[1].chars); textItems2[1].delta = 3; textItems2[1].font = None; textItems2[2].chars = "tutu"; textItems2[2].nchars = strlen(textItems2[2].chars); textItems2[2].delta = 0; textItems2[2].font = fs->fid; XDrawText(dpy, w, gc, 10, 10, textItems2, 3); // PolyText16 XChar2b c2b2[] = { 0, 't', 0, 'x' }; XTextItem16 items16[] = { { &c2bs, 1, -5, None }, { NULL, 0, 0, None }, { c2b2, 2, 0, fs -> fid } }; XDrawText16(dpy, w, gc, 10, 0, items16, SIZEOF(items16)); // ImageText8 XDrawImageString(dpy, w, gc, 10, 10, "toto", 4); // ImageText16 XDrawImageString16(dpy, w, gc, 10, 10, &c2bs, 1); XDrawImageString16(dpy, w, gc, 10, 20, c2b2, 2); // CreateColormap // Don't forget to tell the kids how it was when we had only 8 bits per pixel. Colormap colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None); // FreeColormap XFreeColormap(dpy, colormap); colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None); // CopyColormapAndFree Colormap colormap2 = XCopyColormapAndFree(dpy, colormap); // InstallColormap XInstallColormap(dpy, colormap2); // UninstallColormap XUninstallColormap(dpy, colormap2); // ListInstalledColormaps int num; Colormap *colormapList = XListInstalledColormaps(dpy, w, &num); // AllocColor XColor screen; screen.red = 0; screen.green = 32767; screen.blue = 65535; screen.flags = DoRed | DoGreen | DoBlue; success = XAllocColor(dpy, colormap, &screen); // AllocNamedColor XColor screen2, exact; success = XAllocNamedColor(dpy, colormap, "Wheat", &screen2, &exact); // AllocColorCells unsigned long plane_masks, pixels; success = XAllocColorCells(dpy, colormap, False, &plane_masks, 1, &pixels, 1); // AllocColorPlanes unsigned long rmask, gmask, bmask; success = XAllocColorPlanes(dpy, colormap, False, &pixels, 1, 0, 0, 0, &rmask, &gmask, &bmask); // FreeColors unsigned long pixels2[2] = { screen.pixel, screen2.pixel }; XFreeColors(dpy, colormap, pixels2, 2, 0); // StoreColors success = XAllocColorCells(dpy, colormap, False, NIL, 0, pixels2, 2); // On many contemporary (that is, year 2000) video cards, you can't allocate read / write cells // I want my requests to be sent, however. if (!success) { XSetErrorHandler(errorHandler); } XColor colors[2]; colors[0] = screen; colors[0].pixel = pixels2[0]; colors[1] = screen2; colors[1].pixel = pixels2[1]; XStoreColors(dpy, colormap, colors, 2); // StoreNamedColor XStoreNamedColor(dpy, colormap, "Wheat", colors[0].pixel, DoBlue); XSync(dpy, False); XSetErrorHandler(NIL); // Restore the default handler // QueryColors screen2.pixel = WhitePixelOfScreen(scr); XQueryColor(dpy, colormap, &screen2); // LookupColor success = XLookupColor(dpy, colormap, "DarkCyan", &exact, &screen); // CreateCursor Cursor cursor = XCreatePixmapCursor(dpy, pixmap, None, &exact, colors, 10, 10); // CreateGlyphCursor Cursor cursor2 = XCreateGlyphCursor(dpy, fs -> fid, fs -> fid, 'X', 0, &exact, colors); // FreeCursor XFreeCursor(dpy, cursor2); // RecolorCursor XRecolorCursor(dpy, cursor, colors, &exact); // QueryBestSize success = XQueryBestSize(dpy, CursorShape, RootWindowOfScreen(scr), 100, 20, &width, &height); // QueryExtension int major_opcode, first_event, first_error; XQueryExtension(dpy, "toto", &major_opcode, &first_event, &first_error); // ListExtensions int nextensions; char **extensionList = XListExtensions(dpy, &nextensions); for(char **p = extensionList; nextensions; nextensions--, p++) std::cout << *p << std::endl; XFree(extensionList); // ChangeKeyboardMapping // GetKeyboardMapping int min_keycodes, max_keycodes; XDisplayKeycodes(dpy, &min_keycodes, &max_keycodes); int keysyms_per_keycode; KeySym *keysyms = XGetKeyboardMapping(dpy, min_keycodes, max_keycodes - min_keycodes + 1, &keysyms_per_keycode); XChangeKeyboardMapping(dpy, min_keycodes, keysyms_per_keycode, keysyms, max_keycodes - min_keycodes + 1); // ChangeKeyboardControl // GetKeyboardControl XKeyboardState keyboardState; XGetKeyboardControl(dpy, &keyboardState); XKeyboardControl keyboardValues; keyboardValues.key_click_percent = keyboardState.key_click_percent; keyboardValues.bell_percent = keyboardState.bell_percent; keyboardValues.bell_pitch = keyboardState.bell_pitch; keyboardValues.bell_duration = keyboardState.bell_duration; keyboardValues.led = 1; keyboardValues.led_mode = LedModeOn; keyboardValues.key = min_keycodes; keyboardValues.auto_repeat_mode = AutoRepeatModeDefault; XChangeKeyboardControl(dpy, KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration | KBLed | KBLedMode | KBKey | KBAutoRepeatMode, &keyboardValues); // Bell XBell(dpy, 90); // ChangePointerControl // GetPointerControl int accel_numerator, accel_denominator, threshold; XGetPointerControl(dpy, &accel_numerator, &accel_denominator, &threshold); XChangePointerControl(dpy, True, True, accel_numerator, accel_denominator, threshold); // SetScreenSaver // GetScreenSaver int timeout, interval, prefer_blanking, allow_exposures; XGetScreenSaver(dpy, &timeout, &interval, &prefer_blanking, &allow_exposures); XSetScreenSaver(dpy, timeout, interval, prefer_blanking, allow_exposures); // ChangeHosts // ListHosts int nhosts; Bool state; XHostAddress *hostList = XListHosts(dpy, &nhosts, &state); XHostAddress host; host.family = FamilyInternet; host.length = 4; host.address = "\001\002\003\004"; XAddHost(dpy, &host); // SetAccessControl XSetAccessControl(dpy, EnableAccess); // SetCloseDownMode XSetCloseDownMode(dpy, RetainTemporary); // KillClient XKillClient(dpy, AllTemporary); // RotateProperties Atom properties[] = { XInternAtom(dpy, "CUT_BUFFER0", False), XInternAtom(dpy, "CUT_BUFFER1", False), XInternAtom(dpy, "CUT_BUFFER2", False) }; XRotateWindowProperties(dpy, RootWindowOfScreen(scr), properties, SIZEOF(properties), -1); // ForceScreenSaver XForceScreenSaver(dpy, ScreenSaverReset); // SetPointerMapping // GetPointerMapping unsigned char map[64]; int map_length = XGetPointerMapping(dpy, map, 64); XSetPointerMapping(dpy, map, map_length); // SetModifierMapping // GetModifierMapping XModifierKeymap *modmap = XGetModifierMapping(dpy); XSetModifierMapping(dpy, modmap); // NoOperation XNoOp(dpy); for(;;) { XEvent e; XNextEvent(dpy, &e); std::cout << "Got an event of type " << e.type << std::endl; } }
void X11EmbedContainer::setBackgroundPixmap(QPixmap background) { if (!clientWinId()) { return; } Display *display = QX11Info::display(); Pixmap bg = XCreatePixmap(display, clientWinId(), width(), height(), d->attr.depth); XRenderPictFormat *format = XRenderFindVisualFormat(display, d->attr.visual); Picture picture = XRenderCreatePicture(display, bg, format, 0, 0); //Prevent updating the background-image if possible. Updating can cause a very annoying flicker due to the XClearArea, and thus has to be kept to a minimum QImage image; if (background.paintEngine()->type() != QPaintEngine::X11) image = background.toImage(); // With the raster graphics system this call just returns the backing image, so the image data isn't copied. else image = background.copy().toImage(); //With the X11 graphics engine, we have to create a copy first, else we get a crash if(d->oldBackgroundImage == image) { XFreePixmap(display, bg); XRenderFreePicture(display, picture); return; } d->oldBackgroundImage = image; if (background.paintEngine()->type() != QPaintEngine::X11) { XRenderPictFormat *format = 0; int depth = 0; int bpp = 0; if (image.format() == QImage::Format_ARGB32_Premultiplied) { format = XRenderFindStandardFormat(display, PictStandardARGB32); depth = 32; bpp = 32; } else if (image.format() == QImage::Format_RGB32) { format = XRenderFindStandardFormat(display, PictStandardRGB24); depth = 24; bpp = 32; } else if (image.format() == QImage::Format_RGB16) { bpp = 16; depth = 16; // Try to find a picture format that matches the image format. // The Render spec doesn't require the X server to support 16bpp formats, // so this call can fail. XRenderPictFormat templ; templ.type = PictTypeDirect; templ.direct.alpha = 0; templ.direct.alphaMask = 0; templ.depth = 16; templ.direct.red = 11; templ.direct.redMask = 0x1f; templ.direct.green = 5; templ.direct.greenMask = 0x3f; templ.direct.blue = 0; templ.direct.blueMask = 0x1f; format = XRenderFindFormat(display, PictFormatType | PictFormatDepth | PictFormatAlpha | PictFormatAlphaMask | PictFormatRed | PictFormatRedMask | PictFormatGreen | PictFormatGreenMask | PictFormatBlue | PictFormatBlueMask, &templ, 0); } if (format == 0) { // Convert the image to a standard format. if (image.hasAlphaChannel()) { image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); format = XRenderFindStandardFormat(display, PictStandardARGB32); depth = 32; } else { image = image.convertToFormat(QImage::Format_RGB32); format = XRenderFindStandardFormat(display, PictStandardRGB24); depth = 24; } bpp = 32; } if (image.format() == QImage::Format_RGB32) { // Make sure the would be alpha bits are set to 1. quint32 * const pixels = (quint32*)(const_cast<const QImage*>(&image)->bits()); for (int i = 0; i < image.width() * image.height(); i++) { pixels[i] |= 0xff000000; } } Q_ASSERT(format != 0); // Get the image data into a pixmap XImage ximage; ximage.width = image.width(); ximage.height = image.height(); ximage.xoffset = 0; ximage.format = ZPixmap; // This is a hack to prevent the image data from detaching ximage.data = (char*) const_cast<const QImage*>(&image)->bits(); #if Q_BYTE_ORDER == Q_BIG_ENDIAN ximage.byte_order = MSBFirst; #else ximage.byte_order = LSBFirst; #endif ximage.bitmap_unit = bpp; ximage.bitmap_bit_order = ximage.byte_order; ximage.bitmap_pad = bpp; ximage.depth = depth; ximage.bytes_per_line = image.bytesPerLine(); ximage.bits_per_pixel = bpp; if (depth > 16) { ximage.red_mask = 0x00ff0000; ximage.green_mask = 0x0000ff00; ximage.blue_mask = 0x000000ff; } else { // r5g6b5 ximage.red_mask = 0xf800; ximage.green_mask = 0x07e0; ximage.blue_mask = 0x001f; } ximage.obdata = 0; if (XInitImage(&ximage) == 0) { XRenderFreePicture(display, picture); XFreePixmap(display, bg); return; } Pixmap pm = XCreatePixmap(display, clientWinId(), width(), height(), ximage.depth); GC gc = XCreateGC(display, pm, 0, 0); XPutImage(display, pm, gc, &ximage, 0, 0, 0, 0, width(), height()); XFreeGC(display, gc); Picture pict = XRenderCreatePicture(display, pm, format, 0, 0); XRenderComposite(display, PictOpSrc, pict, None, picture, 0, 0, 0, 0, 0, 0, width(), height()); XRenderFreePicture(display, pict); XFreePixmap(display, pm); } else { XRenderComposite(display, PictOpSrc, background.x11PictureHandle(), None, picture, 0, 0, 0, 0, 0, 0, width(), height()); } XSetWindowBackgroundPixmap(display, clientWinId(), bg); XRenderFreePicture(display, picture); XFreePixmap(display, bg); XClearArea(display, clientWinId(), 0, 0, 0, 0, True); }
void remap(Window win, unsigned int w, unsigned int h) { XClearArea(disp, win, 0, 0, w, h, 0); XCopyArea(disp, canvas, win, gc, 0, 0, w, h, 0, 0); XFlush(disp); }
/* ARGSUSED */ static void Redisplay(Widget gw, XEvent * event, Region region) { XmPannerWidget pw = (XmPannerWidget) gw; Display *dpy = XtDisplay(gw); Window w = XtWindow(gw); int pad = (XmPanner_internal_border(pw) + pw->primitive.highlight_thickness + pw->primitive.shadow_thickness); int dx, dy, width, height; int kx = XmPanner_knob_x(pw) + pad, ky = XmPanner_knob_y(pw) + pad; XmPanner_tmp(pw).showing = FALSE; if (event != NULL) { dx = dy = pw->primitive.highlight_thickness; width = pw->core.width - (2 * dx); height = pw->core.height - (2 * dy); _XmDrawShadows(XtDisplay(gw), XtWindow(gw), pw->primitive.bottom_shadow_GC, pw->primitive.top_shadow_GC, dx, dy, width, height, pw->primitive.shadow_thickness, XmSHADOW_OUT); if (pw->primitive.highlighted) (*(xmPrimitiveClassRec.primitive_class.border_highlight))(gw); else (*(xmPrimitiveClassRec.primitive_class.border_unhighlight))(gw); } if ((XmPanner_tmp(pw).doing && XmPanner_rubber_band(pw)) || (event == NULL)) { XClearArea (XtDisplay(pw), XtWindow(pw), (int) XmPanner_last_x(pw) + pad, (int) XmPanner_last_y(pw) + pad, (unsigned int) (XmPanner_knob_width(pw)), (unsigned int) (XmPanner_knob_height(pw)), False); } XmPanner_last_x(pw) = XmPanner_knob_x(pw); XmPanner_last_y(pw) = XmPanner_knob_y(pw); XmeDrawShadows(XtDisplay(gw), XtWindow(gw), pw->primitive.top_shadow_GC, pw->primitive.bottom_shadow_GC, kx, ky, XmPanner_knob_width(pw), XmPanner_knob_height(pw), pw->primitive.shadow_thickness, XmSHADOW_OUT); dx = kx + pw->primitive.shadow_thickness; dy = ky + pw->primitive.shadow_thickness; if (((int)XmPanner_knob_width(pw) > (int)(2 * pw->primitive.shadow_thickness)) && ((int)XmPanner_knob_height(pw) > (int)(2 * pw->primitive.shadow_thickness))) { width = XmPanner_knob_width(pw) - (2 * pw->primitive.shadow_thickness); height = XmPanner_knob_height(pw) - (2 * pw->primitive.shadow_thickness); XFillRectangle (dpy, w, XmPanner_slider_gc(pw), dx, dy, width, height); } if (XmPanner_tmp(pw).doing && XmPanner_rubber_band(pw)) DRAW_TMP (pw); }
/* text field drawing */ void DrawTextField(struct XObj *xobj) { int x1,y1; int x2,l; int desc,dir,asc; XCharStruct struc; int nl=0; int right=0; l=strlen(xobj->title); if (xobj->value>l) xobj->value=l; if (xobj->value2>l) xobj->value2=l; DrawReliefRect(0,0,xobj->width,xobj->height,xobj,shad,hili); XClearArea(dpy,xobj->win,2,2,xobj->width-4,xobj->height-4,False); XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]); XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&y1,&desc,&struc); /* calcul du premier caractere visible */ /* computation of the first visible character */ while (l-nl >= 1 && XTextWidth(xobj->xfont,xobj->title + nl, xobj->value - nl) > (xobj->width-10)) { nl++; } if (nl>xobj->value3) { xobj->value3 = nl; } else if (xobj->value3>xobj->value) { xobj->value3--; } /* calcul de la longueur du titre visible */ /* computation of the length of the visible title */ while ( l-xobj->value3-right >= 1 && XTextWidth(xobj->xfont,xobj->title + xobj->value3, l - xobj->value3 - right) > (xobj->width-10)) { right++; } #ifdef I18N_MB XmbDrawString(dpy,xobj->win,xobj->xfontset,xobj->gc,5,y1+5, xobj->title + xobj->value3, strlen(xobj->title) - xobj->value3-right); #else XDrawString(dpy,xobj->win,xobj->gc,5,y1+5,xobj->title+xobj->value3, strlen(xobj->title) - xobj->value3-right); #endif /* Dessin de la zone selectionnee */ /* selected zone drawing */ XSetFunction(dpy,xobj->gc,GXinvert); if (xobj->value2>xobj->value) /* Curseur avant la souris */ { x1=XTextWidth(xobj->xfont,&xobj->title[xobj->value3], xobj->value - xobj->value3); x2=XTextWidth(xobj->xfont,&xobj->title[xobj->value], xobj->value2 - xobj->value); } else /* Curseur apres la souris / cursor after the mouse */ { x1=XTextWidth(xobj->xfont,&xobj->title[xobj->value3], xobj->value2 - xobj->value3); x2=XTextWidth(xobj->xfont,&xobj->title[xobj->value2], xobj->value - xobj->value2); } XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&asc,&desc,&struc); XFillRectangle(dpy,xobj->win,xobj->gc,x1+5,7,x2,y1+desc-2); XSetFunction(dpy,xobj->gc,GXcopy); /* Dessin du point d'insertion */ /* insertion point drawing */ DrawPointTxt(xobj,xobj->TabColor[fore]); }
int drawFont(int count, char *msg) { int x1; int y1; int i; int index; #ifdef CHANGE_FONT_SIZE int w; int h; int actual_count; char **font_list; #endif if (count <= 0) { return 0; // nothing to do } srandom(time(NULL)); XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0); #ifdef CHANGE_FONT_SIZE font_list = XListFonts(g_disp, "−*−courier−*−*−*−*−0−0−*−*−*−0−*−*", 2000, &actual_count); if (!font_list) { printf("actual_count=%d\n", actual_count); for (i = 0; i < actual_count; i++) { printf("%s\n", font_list[i]); } XFreeFontNames(font_list); } else { printf("XListFonts() reted NULL\n"); } #endif srandom(time(NULL)); for (i = 0, index = 0; i < count; i++) { x1 = random() % g_winWidth; y1 = random() % g_winHeight; XSetForeground(g_disp, g_gc, g_colors[index++].pixel); if (index == MAX_COLORS) { index = 0; } XDrawString(g_disp, g_win, g_gc, x1, y1, msg, strlen(msg)); XFlush(g_disp); usleep(g_delay_dur); } return 0; // nothing to do }
string GraphicWindow::get_string(string outstr) { XEvent report; string instring; char instr[50]; char buffer[3]; int buffsize = 3; KeySym keysym; XComposeStatus compose; int count, length; int str_x; // initial x position, at the end of the prompt string int str_y; // initial yposition int curr_x; // current x position (measured from str_x) int direction; // draw chars l->r int ascent; // above font's baseline int descent; // below font's baseline XCharStruct overall; _display_string=outstr; statusline_prompt(outstr); XTextExtents(_fontinfo_ptr, _display_string.c_str(), _display_string.length(), &direction, &ascent, &descent, &overall); str_x = overall.width; curr_x = overall.width; str_y = ascent; // set initial cursor position instr[0] = '\0'; curr_x = put_string(instr, str_x, curr_x); //Event loop while(1) { XNextEvent(display, &report); switch (report.type) { case Expose: cwin.repaint(); break; case KeyPress: /* get characters until carriage return */ count = XLookupString(&(report.xkey), buffer, buffsize, &keysym, &compose); /* got a carriage return */ if ((keysym == XK_Return) || (keysym == XK_KP_Enter) || (keysym == XK_Linefeed)) { XClearArea(display, win, 0, 0, /*clear from top*/ 0, /*clear to right edge of screen*/ ascent + descent + 1, 0 /* generate expoure events */); instring = instr; return instring; } /* eat white space */ else if (((keysym >= XK_KP_Space) && (keysym <= XK_KP_9)) || ((keysym >= XK_space) && (keysym <= XK_asciitilde))) { if ((strlen(instr) + strlen(buffer)) >= 50) XBell(display, 100); else { buffer[1] = '\0'; strcat (instr, buffer); } } /* got a delete key */ else if ((keysym == XK_BackSpace) || (keysym == XK_Delete)) { if ((length = strlen(instr)) > 0) { // resize the string instr[length-1] = '\0'; } else XBell(display, 100); } /* display the new string, and reposition cursor */ curr_x = put_string(instr, str_x, curr_x); } } return instring; // never get here but it keeps compiler happy :)! }
static void X_flush(aa_context * c) { struct xdriverdata *d=c->driverdata; int x, y, attr; int xs = 0, ys = 0; int l, same; int s = 0; int pos; attr = AA_NORMAL; alloctables(d); drawed = 0; area = 0; if (aa_imgwidth(c) != d->imgwidth || aa_imgheight(c) != d->imgheight) { if (d->previoust != NULL) free(d->previoust), free(d->previousa); d->previoust=NULL; d->previousa=NULL; d->imgwidth = aa_imgwidth(c); d->imgheight =aa_imgheight(c); if (!d->pixmapmode) { XSetWindowBackground(d->dp, d->wi, d->inverted ? d->invertedblack : d->black); } else { XFillRectangle(d->dp, d->pi, d->blackGC, 0, 0, d->pixelwidth, d->pixelheight); XSetWindowBackgroundPixmap(d->dp, d->wi, d->pi); XClearWindow(d->dp, d->wi); } } nrectangles[0] = 0; nrectangles[1] = 0; nrectangles[2] = 0; nrectangles[3] = 0; if (d->previoust == NULL) { d->previoust = malloc(d->width * d->height); d->previousa = calloc(d->width * d->height, 1); memset(d->previoust, ' ', d->width * d->height); } for (y = 0; y < aa_scrheight(c); y++) { s = l = 0; xs = 0; ys = y; for (x = 0; x < aa_scrwidth(c); x++) { pos = x + y * aa_scrwidth(c); if (s > 5 || (c->attrbuffer[pos] != attr && (c->textbuffer[pos] != ' ' || Black[c->attrbuffer[pos]] || Black[attr]))) { if (l - s) MyDrawString(d,attr, xs, ys, &c->textbuffer[xs + ys * aa_scrwidth(c)], l - s); attr = c->attrbuffer[pos]; s = l = 0; xs = x; ys = y; } if ((d->previoust[pos] == c->textbuffer[pos] && d->previousa[pos] == c->attrbuffer[pos]) || (!Black[attr] && d->previoust[pos] == ' ' && c->textbuffer[pos] == ' ' && !Black[d->previousa[pos]])) same = 1; else same = 0; if (xs == x && same) xs++; else { if (same) s++; else s = 0; l++; } } if (l - s) MyDrawString(d,attr, xs, ys, &c->textbuffer[xs + ys * aa_scrwidth(c)], l - s); } if (drawed) { memcpy(d->previousa, c->attrbuffer, d->width * d->height); memcpy(d->previoust, c->textbuffer, d->width * d->height); if (nrectangles[0]) XFillRectangles(d->dp, dr, d->blackGC, &rectangles(0, 0), nrectangles[0]); if (nrectangles[1]) XFillRectangles(d->dp, dr, d->normalGC, &rectangles(1, 0), nrectangles[1]); if (nrectangles[2]) XFillRectangles(d->dp, dr, d->specialGC, &rectangles(2, 0), nrectangles[2]); if (d->cvisible) XDrawLine(d->dp, dr, d->normalGC, d->Xpos * d->realfontwidth, (d->Ypos + 1) * d->fontheight - 1, (d->Xpos + 1) * d->realfontwidth - 1, (d->Ypos + 1) * d->fontheight - 1); for (y = 0; y < d->height; y++) { for (x = 0; x < NATT; x++) { if (nitem[y][x]) { X_setattr(d,x); XDrawText(d->dp, dr, d->currGC, 0, (y + 1) * d->fontheight - d->font_s->descent, &texty(y, x, 0), nitem[y][x]); if (x == 4) XDrawText(d->dp, dr, d->currGC, 1, (y + 1) * d->fontheight - d->font_s->descent, &texty(y, x, 0), nitem[y][x]); } } } if (d->pixmapmode) { if (nrectangles[3] && area < d->width*d->height/2 && nrectangles[3] < 5) { int i; /*fprintf (stderr, "%i %i\n",nrectangles[3], area);*/ for (i = 0; i < nrectangles[3]; i++) XClearArea (d->dp, d->wi, rectangles(3, i).x, rectangles(3,i).y, rectangles(3,i).width, rectangles(3,i).height, 0); } else XClearWindow(d->dp, d->wi); } /*if(!d->pixmapmode) */ XSync(d->dp, 0); } freetables(); }
void EZX_ClearRectangle(EZXW_p w, int left, int top,int width, int height) { XClearArea(theDisplay, w->w, left, top, width, height, False); }
/* * Clear out the view subwindow. If possible, delay the visible effect * until all the lines have been drawn (since this is only called by * ShowView(), which is about to draw a bunch of lines). */ void ClearView(void) { XClearArea(dpy, mwWindow, VIEW_X_ORIGIN, VIEW_Y_ORIGIN, VIEW_X_DIM, VIEW_Y_DIM, False); }
void EClearArea(Win win, int x, int y, unsigned int w, unsigned int h) { XClearArea(disp, win->xwin, x, y, w, h, False); }
void drawLightTransArrow(void) { int i; float f; /*** Draw the intensity potentiometer window. ***/ XClearArea(dsply,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX, (control->buttonQueue[lightTranslucent]).buttonY-5, (control->buttonQueue[lightTranslucent]).buttonWidth, (control->buttonQueue[lightTranslucent]).buttonHeight+10, False); GDrawLine(controlMessageGC,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX, (control->buttonQueue[lightTranslucent]).buttonY, (control->buttonQueue[lightTranslucent]).buttonX, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption); GDrawLine(controlMessageGC,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX + 1, (control->buttonQueue[lightTranslucent]).buttonY, (control->buttonQueue[lightTranslucent]).buttonX + (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, (control->buttonQueue[lightTranslucent]).buttonY,Xoption); GDrawLine(controlMessageGC,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX + 1, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).yHalf/2, (control->buttonQueue[lightTranslucent]).buttonX + (control->buttonQueue[lightTranslucent]).buttonWidth * 2/10, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).yHalf/2,Xoption); GDrawLine(controlMessageGC,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX + 1, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).yHalf, (control->buttonQueue[lightTranslucent]).buttonX + (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).yHalf,Xoption); GDrawLine(controlMessageGC,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX + 1, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).buttonHeight*3/4, (control->buttonQueue[lightTranslucent]).buttonX + (control->buttonQueue[lightTranslucent]).buttonWidth * 2/10, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).buttonHeight*3/4,Xoption); GDrawLine(controlMessageGC,lightingWindow, (control->buttonQueue[lightTranslucent]).buttonX + 1, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).buttonHeight, (control->buttonQueue[lightTranslucent]).buttonX + (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, (control->buttonQueue[lightTranslucent]).buttonY + (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption); /*** Draw the intensity selection arrow ***/ GSetForeground(lightingGC,(float)lightingTransArrowColor,Xoption); f = (control->buttonQueue[lightTranslucent].buttonY + control->buttonQueue[lightTranslucent].buttonHeight) - (tempLightIntensity * control->buttonQueue[lightTranslucent].buttonHeight); i = f; GDrawLine(lightingGC, lightingWindow, arrowHead + 10, i, arrowHead + 22, i + 2, Xoption); GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i + 2, arrowHead + 22, i - 2, Xoption); GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i - 2, arrowHead + 10, i, Xoption); } /* drawLightTransArrow() */
void drawClipXBut (void) { XClearArea(dsply,volumeWindow,clipXButX,clipXButY, majorAxis+blank,minorAxis+blank,False); GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX-3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf-3, (control->buttonQueue[clipXBut]).buttonX, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX-3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf+3, (control->buttonQueue[clipXBut]).buttonX, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth+3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf-3, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth+3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf+3, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GSetForeground(trashGC,(float)monoColor(arcColor),Xoption); GFillArc(trashGC,volumeWindow, (int)(xClipMinN * (majorAxis-tinyArc) + clipXButX), /* x value */ (int)(clipXButY + minorAxis/2 + 1), /* y value */ arcSize,arcSize,0,360*64,Xoption); /* 64 units per degree */ GFillArc(trashGC,volumeWindow, (int)(xClipMaxN * (majorAxis-tinyArc) + clipXButX), /* x value */ (int)(clipXButY + minorAxis/2 - 7), /* y value */ arcSize,arcSize,0,360*64,Xoption); /* 64 units per degree */ GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption); GDrawString(volumeGC,volumeWindow,clipXMessX,clipXMessY,"X",1,Xoption); }