void ws_status_timer(Timer tm, Name status) { UINT id; if ( (id = getIdTimer(tm)) ) { KillTimer(NULL, id); deleteHashTable(TimerTable, toInt(id)); setIdTimer(tm, 0); } if ( status != NAME_idle ) { long msec = (long) (valReal(tm->interval) * 1000.0); if ( (id = SetTimer(NULL, 0, (UINT)msec, (TIMERPROC) timer_proc)) ) { if ( !TimerTable ) { TimerTable = globalObject(CtoName("active_timers"), ClassHashTable, EAV); assign(TimerTable, refer, NAME_none); } appendHashTable(TimerTable, toInt(id), tm); setIdTimer(tm, id); DEBUG(NAME_timer, Cprintf("Created timer of %d milliseconds (id = %d)\n", msec, id)); } else Cprintf("Failed SetTimer()\n"); } }
static void cmd_exec(int argc, const char * const * argv) { #define CMD_EXEC_MAX_ARGS (8) int args[CMD_EXEC_MAX_ARGS]; int fidx; int i, exec_res; char *eptr; if (argc < 1 || argc > CMD_EXEC_MAX_ARGS+1) goto syntax_err; fidx = csp_vm_find_func(argv[0]); if (fidx < 0){ Cprintf("not found\n"); } for (i=1;i<argc && i<CMD_EXEC_MAX_ARGS+1;i++){ args[i-1] = strtoul(argv[i], &eptr, 0); if (!eptr || *eptr != 0){ goto syntax_err; } } exec_res = csp_vm_run_function(1000, fidx, argc-1, args); Cprintf("\nexec %s(): %d %d\n", argv[0], exec_res, csp_vm_get_call_result()); return; syntax_err: Cprintf("Usage: exec <name> [args...]\n"); }
int main() { BOOL bSuccess; int i; char szBuf[30]; InitConsoleIO(); // must call this at startup ClrScr(); // clear the screen for ( i=0; i < 20; i += 2 ) { // QUESTION H what does the next line do? GotoXY(i,i); // make a message and put it out sprintf( szBuf, "%d,%d", i, 2*i ); bSuccess = PutText(szBuf); // test PutText. if (!bSuccess) printf("WriteConsoleOutputCharacter error\n"); } // make some cool messages in different colours TextColour( BC_RED ); TextBackground( BC_GREEN ); Cprintf("Cool %d ", i++); TextColour( BC_BLACK ); TextBackground( BC_LIGHTGRAY ); Cprintf("colours %d ", i++); TextColour( BC_LIGHTMAGENTA ); TextBackground( BC_BLUE ); Cprintf(" Eh %d?", i); return(1); }
static unsigned long colourPixel(Display *disp, int depth, Colormap cmap, Table t, int r, int g, int b) { unsigned long pixel; unsigned long direct = (r << 16) + (g << 8) + b; XColor c; if ( (pixel = memberTable(t, direct)) != NOPIXEL ) return pixel; ncolours++; c.red = r * 257; c.green = g * 257; c.blue = b * 257; if ( !XAllocColor(disp, cmap, &c) ) { if ( !allocNearestColour(disp, cmap, depth, DEFAULT, &c) ) { Cprintf("PNM: failed to alloc pixel %d/%d/%d\n", r, g, b); c.pixel = 0; nfailed++; } } addTable(t, direct, c.pixel); DEBUG(NAME_ppm, Cprintf("PNM: Colour %d %d %d on pixel %d\n", r, g, b, c.pixel)); return c.pixel; }
static int x_error_handler(Display *display, XErrorEvent *error) { if ( !catchedErrorPce(PCE, NAME_xError) ) { char msg[1024]; char request[100]; char buf[100]; /* XSetInputFocus() can generate a */ /* BadMatch that is hard to avoid */ if ( error->request_code == X_SetInputFocus && error->error_code == BadMatch ) return 0; XGetErrorText(display, error->error_code, msg, 1024); sprintf(buf, "%d", error->request_code); XGetErrorDatabaseText(display, "XRequest", buf, "Unknown request", request, 100); Cprintf("X error of failed request: %s\n", msg); Cprintf("Major opcode of failed request: %d (%s)\n", error->request_code, request); Cprintf("Minor opcode of failed request: %d\n", error->minor_code); Cprintf("Resource id in failed request: 0x%x\n", (unsigned int) error->resourceid); Cprintf("Serial number of failed request: %ld\n", error->serial); errorPce(NIL, NAME_xError); } return 0; /* what to return here? */ }
static status parse_font(char *s, LOGFONT *lfont) { while(*s) { char att[100]; int n = -1; char *q; for(q=att; isalpha(*s); *q++ = *s++) ; *q = EOS; if ( stricmp(att, "height") == 0 ) n=long_attribute(s, &lfont->lfHeight); else if ( stricmp(att, "width") == 0 ) n=long_attribute(s, &lfont->lfWidth); else if ( stricmp(att, "escapement") == 0 ) n=long_attribute(s, &lfont->lfEscapement); else if ( stricmp(att, "orientation") == 0 ) n=long_attribute(s, &lfont->lfOrientation); else if ( stricmp(att, "weight") == 0 ) n=long_attribute(s, &lfont->lfWeight); else if ( stricmp(att, "italic") == 0 ) n=bool_attribute(s, &lfont->lfItalic); else if ( stricmp(att, "underline") == 0 ) n=bool_attribute(s, &lfont->lfUnderline); else if ( stricmp(att, "strikeout") == 0 ) n=bool_attribute(s, &lfont->lfStrikeOut); else if ( stricmp(att, "charset") == 0 ) n=named_attribute(s, charset_names, 0xff, &lfont->lfCharSet); else if ( stricmp(att, "outprecision") == 0 ) n=named_attribute(s, outprecision_names, 0xff, &lfont->lfOutPrecision); else if ( stricmp(att, "clipprecision") == 0 ) n=named_attribute(s, clipprecision_names, 0xff, &lfont->lfClipPrecision); else if ( stricmp(att, "quality") == 0 ) n=named_attribute(s, quality_names, 0xff, &lfont->lfQuality); else if ( stricmp(att, "pitch") == 0 ) n=named_attribute(s, pitch_names, 0x3, &lfont->lfPitchAndFamily); else if ( stricmp(att, "family") == 0 ) n=named_attribute(s, family_names, 0xf8, &lfont->lfPitchAndFamily); else if ( stricmp(att, "face") == 0 ) n=string_attribute(s, lfont->lfFaceName, LF_FACESIZE); else Cprintf("Bad font-attribute name: %s\n", att); if ( n < 0 ) { Cprintf("Bad value for font-attribute %s\n", att); while( *s && *s != ':' ) s++; } else { DEBUG(NAME_font, Cprintf("att %s: read %d chars\n", att, n)); s += n; if ( *s == ':' ) s++; } } succeed; }
status ws_create_window(PceWindow sw, PceWindow parent) { Widget w; DisplayObj d = getDisplayGraphical((Graphical)sw); /* create the widget */ { Arg args[8]; Cardinal n = 0; int pen = valInt(sw->pen); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Actually, it appears Xt is ignoring the geometry parameters. Hence, ws_realise_frame() sends ->geometry to all windows. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ XtSetArg(args[n], XtNx, valInt(sw->area->x)); n++; XtSetArg(args[n], XtNy, valInt(sw->area->y)); n++; XtSetArg(args[n], XtNwidth, valInt(sw->area->w) - 2*pen); n++; XtSetArg(args[n], XtNheight, valInt(sw->area->h) - 2*pen); n++; XtSetArg(args[n], XtNborderWidth, pen); n++; XtSetArg(args[n], XtNinput, True); n++; if ( instanceOfObject(sw->background, ClassColour) ) { XtSetArg(args[n], XtNbackground, getPixelColour(sw->background, d)); n++; } else { Pixmap pm = (Pixmap) getXrefObject(sw->background, d); XtSetArg(args[n], XtNbackgroundPixmap, pm); n++; } DEBUG(NAME_create, Cprintf("Calling XtCreateWidget ...")); w = XtCreateWidget(strName(sw->name), canvasWidgetClass, isDefault(parent) ? widgetFrame(sw->frame) : widgetWindow(parent), args, n); DEBUG(NAME_create, Cprintf("Widget = %p\n", w)); } if ( !w ) return errorPce(w, NAME_createFailed); setWidgetWindow(sw, w); XtAddCallback(w, XtNeventCallback, event_window, sw); XtAddCallback(w, XtNexposeCallback, expose_window, sw); XtAddCallback(w, XtNresizeCallback, resize_window, sw); XtAddCallback(w, XtNdestroyCallback, destroy_window, sw); if ( notDefault(parent) ) /* make a sub-window */ { XtManageChild(w); send(sw, NAME_displayed, ON, EAV); } succeed; }
void Wait () /* Busy-wait for a key from keyboard */ { int flag; Cprintf ("Press any key to continue... ") ; flag = Mod_int (INT_ENABLE); while( Get_char() == NULL ) ; Mod_int (flag); Cprintf ("\n") ; }
/** Aux function **/ int test3a_Q( int argc, char** argv ) { if( argv[0][0] != 'M' ) { Cprintf( "%s.q ", argv[0] ); } else { Cprintf( "notes to " ); } return 0; }
int Proc( int argc, char** argv ) { PROCPTR p; int pid; char c; Cprintf( "test1i: Hello!\n" ); Cprintf( "test1i: [Loading test1a...]\n" ); p = Load_module( "test1a.mod" ); Cprintf( "test1i: proc == %p\n", p ); Cprintf( "test1i: [Starting test1a...]\n" ); pid = Proc_start( p, child_argc, child_argv ); Cprintf( "test1i: pid == %d\n", pid ); Cprintf( "test1i: [Closing test1a...]\n" ); Close_module( "test1a.mod" ); Cprintf( "test1i: [Sleeping until keypress...]\n" ); c = Get_char(); Cprintf( "test1i: c == '%c'\n", c ); Cprintf( "test1i: [Terminating...]\n" ); return 0; }
static void cmd_help(int argc, const char * const * argv) { const struct shell_command *cmd; int i; Cprintf("Commands:\n"); for (i=0;i<shell_commands_count;i++){ cmd = &shell_commands[i]; Cprintf(" %-16s - %s\n", cmd->name, cmd->descr); } }
void ws_discard_input(const char *msg) { if ( dispatch_fd >= 0 && input_on_fd(dispatch_fd) ) { char buf[1024]; Cprintf("%s; discarding input ...", msg); if ( read(dispatch_fd, buf, sizeof(buf)) >= 0 ) Cprintf("ok\n"); else Cprintf("failed\n"); } }
static void cmd_load(int argc, const char * const * argv) { if (argc != 0) goto syntax_err; Cprintf("Expecting script code.\nEnd with a Ctrl+D (ASCII char code 4).\n"); load_script_from_console(); return; syntax_err: Cprintf("Usage: load\n"); }
int ws_provide_selection(int format) { DisplayObj d = CurrentDisplay(NIL); Hyper h; Function msg; Name which = NAME_primary; Name hypername = getAppendName(which, NAME_selectionOwner); Name type; if ( d && notNil(d) && (h = getFindHyperObject(d, hypername, DEFAULT)) && (type = getAttributeObject(h, NAME_type)) && (msg = getAttributeObject(h, NAME_convertFunction)) && (msg = checkType(msg, TypeFunction, NIL)) ) { Any val; DEBUG(NAME_selection, Cprintf("Provide %s selection of type %s\n", pp(which), pp(type))); if ( !(val = getForwardReceiverFunction(msg, h->to, which, type, EAV)) ) return FALSE; DEBUG(NAME_selection, Cprintf("Got %s\n", pp(val))); if ( type == NAME_text ) { CharArray ca = checkType(val, TypeCharArray, NIL); if ( ca ) { String s = &ca->data; HGLOBAL mem = ws_string_to_global_mem(s); if ( mem ) SetClipboardData(CF_UNICODETEXT, mem); return TRUE; } } else if ( type == NAME_emf || type == NAME_wmf ) { Any mf = checkType(val, nameToType(NAME_winMetafile), NIL); if ( mf ) { DEBUG(NAME_selection, Cprintf("Providing win_metafile\n")); return ws_on_clipboard_metafile(mf, type); } } else return errorPce(d, NAME_noSelectionType, type); } return FALSE; }
int main(int argc, char* argv[]) { if ( !pceInitialise(0, NULL, argc, argv) ) { Cprintf("Sorry, failed to initialise XPCE\n"); exit(1); } if ( !pceInitApplication(argc, argv) ) { Cprintf("Failed to run pceInitApplication()\n"); exit(1); } for(;;) pceDispatch(0, 1000); }
status ws_create_font(FontObj f, DisplayObj d) { XpceFontInfo xref; DisplayWsXref r = d->ws_ref; XftFont *xft = NULL; if ( !instanceOfObject(f->x_name, ClassCharArray) || !isstrA(&f->x_name->data) ) /* HACK */ { XftPattern *p = XftPatternCreate(); XftPattern *match; FcResult fcrc; int i; char *fam; int mono = FALSE; Real scale = getClassVariableValueObject(f, NAME_scale); double fscale = (scale ? valReal(scale) : 1.0); if ( f->family == NAME_screen ) { fam = "monospace"; mono = TRUE; } else fam = strName(f->family); XftPatternAddString(p, XFT_FAMILY, fam); XftPatternAddDouble(p, XFT_PIXEL_SIZE, (double)valInt(f->points)*fscale); if ( f->style == NAME_italic ) XftPatternAddInteger(p, XFT_SLANT, XFT_SLANT_ITALIC); else if ( f->style == NAME_roman ) XftPatternAddInteger(p, XFT_SLANT, XFT_SLANT_ROMAN); else if ( f->style == NAME_bold ) XftPatternAddInteger(p, XFT_WEIGHT, XFT_WEIGHT_BOLD); if ( mono ) { DEBUG(NAME_font, Cprintf("Asking for fixed\n")); XftPatternAddInteger(p, XFT_SPACING, XFT_MONO); } if ( !(match = XftFontMatch(r->display_xref, r->screen, p, &fcrc)) ) { DEBUG(NAME_font, Cprintf("XftFontMatch() failed. Calling replaceFont()\n")); return replaceFont(f, d); } #ifdef HAVE_XFTNAMEUNPARSE DEBUG(NAME_font, { char buf[1024]; XftNameUnparse(match, buf, sizeof(buf)); Cprintf("Match = '%s'\n", buf); });
status getXYHandle(Handle h, Graphical gr, Device dev, Int *X, Int *Y) { Int x, y, gx, gy; if ( isDefault(dev) ) dev = gr->device; TRY( get_absolute_xy_graphical(gr, &dev, &gx, &gy) ); if ( X ) { TRY(x = getValueExpression(h->xPosition, VarW, gr->area->w, VarH, gr->area->h, EAV)); *X = add(x, gx); } if ( Y ) { TRY(y = getValueExpression(h->yPosition, VarW, gr->area->w, VarH, gr->area->h, EAV)); *Y = add(y, gy); } DEBUG(NAME_handle, Cprintf("handle %s on gr=%s,dev=%s at x=%s,y=%s\n", pp(h->name), pp(gr), pp(dev), X?"":pp(*X), Y?"":pp(*Y))); succeed; }
static status forwardsSpatial(Spatial s, Any from, Any to) { Int xref, yref; Int tX, tY, tW, tH; Area f, t; TRY(f = get(from, NAME_area, EAV)); TRY(t = get(to, NAME_area, EAV)); CALC(xref,s->xFrom,getVar(s->xFrom,VarXref,VarX,f->x,VarW,f->w, EAV),f->x); CALC(yref,s->yFrom,getVar(s->yFrom,VarYref,VarY,f->y,VarH,f->h, EAV),f->y); CALC(tW, s->wTo, getVar(s->wTo, VarW2, VarW, f->w, EAV), t->w); CALC(tH, s->hTo, getVar(s->hTo, VarH2, VarH, f->h, EAV), t->h); CALC(tX, s->xTo,getVar(s->xTo, VarX, VarXref, xref, VarW, tW, EAV), t->x); CALC(tY, s->yTo,getVar(s->yTo, VarY, VarYref, yref, VarH, tH, EAV), t->y); DEBUG(NAME_spatial, Cprintf("%s->f: (%s,%s) -- %ld,%ld,%ld,%ld ==> (%ld, %ld, %ld, %ld)\n", pp(s), pp(from), pp(to), valInt(f->x), valInt(f->y), valInt(f->w), valInt(f->h), valInt(tX), valInt(tY), valInt(tW), valInt(tH))); if (t->x != tX || t->y != tY || t->w != tW || t->h != tH) return send(to, NAME_set, tX, tY, tW, tH, EAV); succeed; }
static status updatePopupGesture(PopupGesture g, EventObj ev) { PopupObj p; Any rec = getMasterEvent(ev); DEBUG(NAME_popup, Cprintf("updatePopupGesture(): rec=%s\n", pp(rec))); if ( notNil(g->popup) ) { if ( instanceOfObject(g->popup, ClassFunction) ) { TRY( p = getForwardReceiverFunction((Function) g->popup, rec, rec, ev, EAV) ); TRY( p = checkType(p, nameToType(NAME_popup), g)); } else p = g->popup; } else { if ( !(p = get(rec, NAME_popup, EAV)) || !instanceOfObject(p, ClassPopup) ) fail; } assign(g, current, p); if ( isNil(g->context) ) assign(g, context, notNil(p->context) ? p->context : rec); send(p, NAME_update, g->context, EAV); if ( p->active == OFF || emptyChain(p->members) ) { send(g, NAME_cancel, ev, EAV); fail; } succeed; }
// execute callback static int rlexecute (int argc, const char * const * argv) { const struct shell_command *cmd; int i, found=0; if (argc < 1) return 0; for (i=0;i<shell_commands_count;i++){ /* TODO: sort shell_commands and use a binary search */ cmd = &shell_commands[i]; if (strcmp(argv[0], cmd->name) == 0){ found = 1; cmd->handler(argc-1, &argv[1]); break; } } if (!found){ Cprintf("Unknown command: %s\nType 'help' for help\n", argv[0]); } return 0; }
static int gif_extension(int ext, void *data, void *closure) { XpmImage *img = closure; switch(ext) { case GIFEXT_TRANSPARENT: { XpmColor *c; long i = (long)(intptr_t)data; DEBUG(NAME_gif, Cprintf("Using %d as transparent (ncolors=%d)\n", i, img->ncolors)); if ( i < 0 || i >= img->ncolors ) return GIF_INVALID; c = &img->colorTable[i]; strcpy(c->c_color, "None"); /* malloced 8 bytes, so ok. */ break; } default: assert(0); } return GIF_OK; }
static void ws_open_colourmap(ColourMap cm) { if ( !getExistingPaletteColourMap(cm) && notNil(cm->colours) ) { int size = valInt(cm->colours->size); LOGPALETTE *lp = pceMalloc(offset(LOGPALETTE, palPalEntry[size])); PALETTEENTRY *pe = &lp->palPalEntry[0]; HPALETTE hpal; int n, nc = 0; DisplayObj d = CurrentDisplay(NIL); for(n=0; n<size; n++) { Colour c = cm->colours->elements[n]; if ( isName(c) && (c = checkType(c, TypeColour, NIL)) ) elementVector(cm->colours, toInt(n+1), c); if ( instanceOfObject(c, ClassColour) ) { if ( c->kind == NAME_named ) ws_create_colour(c, d); pe->peRed = valInt(c->red) >> 8; pe->peGreen = valInt(c->green) >> 8; pe->peBlue = valInt(c->blue) >> 8; pe->peFlags = 0; pe++; nc++; } else Cprintf("%s is not a colour\n", pp(c)); }
static HPALETTE CreateCCPalette(int size) { int le = size * size * size; LOGPALETTE *lp = pceMalloc(offset(LOGPALETTE, palPalEntry[le])); int i, r, g, b; PALETTEENTRY *pe = &lp->palPalEntry[0]; BYTE *intensity = alloca(size * sizeof(BYTE)); HPALETTE hpal; lp->palVersion = 0x300; lp->palNumEntries = le; for(i=0; i<size; i++) intensity[i] = (255*i)/(size-1); /* gamma correction? */ for(r=0; r<size; r++) { for(g = 0; g<size; g++) { for(b = 0; b<size; b++) { pe->peRed = intensity[r]; pe->peGreen = intensity[g]; pe->peBlue = intensity[b]; pe->peFlags = 0; pe++; } } } if ( !(hpal = CreatePalette(lp)) ) Cprintf("Failed to create color cube with %d entries\n", le); return hpal; }
static status eventHandler(Handler h, EventObj ev) { DEBUG(NAME_post, Cprintf("eventHandler(%s, %s)\n", pp(h), pp(ev))); if ( isAEvent(ev, h->event) ) { if (isDefault(h->region)) { if (isNil(h->message)) succeed; return forwardReceiverCodev(h->message, getMasterEvent(ev), 1, (Any *)&ev); } else { Graphical gr = ev->receiver; if ( insideRegion(h->region, gr->area, getAreaPositionEvent(ev, gr)) == SUCCEED ) { if ( notNil(h->message) ) return forwardReceiverCodev(h->message, getMasterEvent(ev), 1, (Any *)&ev); succeed; } } } fail; }
void assocObjectToHWND(HWND hwnd, Any obj) { int key = handleKey(hwnd); WinAssoc *p = &wintable[key]; WinAssoc a = *p; if ( !lock_initialized ) /* we are serialized by the XPCE */ { lock_initialized = TRUE; /* lock, so this must be safe */ InitializeCriticalSection(&lock); } if ( isNil(obj) ) /* delete from table */ { EnterCriticalSection(&lock); for( ; a ; p = &a->next, a = a->next ) { if ( a->hwnd == hwnd ) { *p = a->next; unalloc(sizeof(winassoc), a); break; } } LeaveCriticalSection(&lock); /* not in the table!? */ } else { WinAssoc n = alloc(sizeof(winassoc)); n->hwnd = hwnd; n->object = obj; n->next = *p; *p = n; } DEBUG(NAME_window, Cprintf("Binding 0x%04x --> %s\n", hwnd, pp(obj))); }
static status backwardsSpatial(Spatial s, Any from, Any to) { Int xref, yref; Int fW, fH, fX, fY; Area f, t; TRY(f = get(from, NAME_area, EAV)); TRY(t = get(to, NAME_area, EAV)); CALC(xref, s->xTo, getVar(s->xTo,VarXref,VarX,t->x,VarW,t->w,EAV), t->x); CALC(yref, s->yTo, getVar(s->yTo,VarYref,VarY,t->y,VarH,t->h,EAV), t->y); CALC(fW, s->wTo, getVar(s->wTo,VarW,VarW2,t->w,EAV), f->w); CALC(fH, s->hTo, getVar(s->hTo,VarH,VarH2,t->h,EAV), f->h); CALC(fX, s->xTo, getVar(s->xFrom,VarX,VarXref,xref,VarW,f->w,EAV), f->x); CALC(fY, s->yTo, getVar(s->yFrom,VarY,VarYref,yref,VarH,f->h,EAV), f->y); DEBUG(NAME_spatial, Cprintf("%s->b: (%s,%s) -- %ld,%ld,%ld,%ld ==> (%ld, %ld, %ld, %ld)\n", pp(s), pp(from), pp(to), valInt(t->x), valInt(t->y), valInt(t->w), valInt(t->h), valInt(fX), valInt(fY), valInt(fW), valInt(fH))); if (f->x != fX || f->y != fY || f->w != fW || f->h != fH) return send(from, NAME_set, fX, fY, fW, fH, EAV); succeed; }
void considerLocStillEvent() { if ( !loc_still_posted ) { unsigned long now = mclock(); if ( now - host_last_time < (unsigned long)loc_still_time ) { DEBUG(NAME_locStill, Cprintf("TimeDiff = %d (ignored)\n", now - host_last_time)); return; } if ( !pceMTTryLock(LOCK_PCE) ) return; if ( instanceOfObject(last_window, ClassWindow) && !onFlag(last_window, F_FREED|F_FREEING) && valInt(last_x) > 0 && valInt(last_y) > 0 ) { ServiceMode(is_service_window(last_window), { AnswerMark mark; EventObj e; markAnswerStack(mark); e = newObject(ClassEvent, NAME_locStill, last_window, last_x, last_y, last_buttons, toInt(last_time + now - host_last_time), EAV); addCodeReference(e); postNamedEvent(e, (Graphical) last_window, DEFAULT, NAME_postEvent); delCodeReference(e); freeableObj(e); rewindAnswerStack(mark, NIL); }) }
static int scrollGesture(Gesture g) { Name msg; Int amount; Graphical gr; Name dir = NAME_forwards; if ( !scrollMessage(g, g->drag_scroll_event, &gr, &msg, &amount) ) fail; if ( valInt(amount) < 0 ) { dir = NAME_backwards; amount = toInt(-valInt(amount)); } if ( hasSendMethodObject(gr, msg) && send(gr, msg, dir, NAME_line, amount, EAV) ) { EventObj ev = getCloneObject(g->drag_scroll_event); /* TBD: optimise? */ DEBUG(NAME_dragScroll, Cprintf("Drag event = %s, receiver %s\n", pp(ev->id), pp(ev->receiver))); ComputeGraphical(gr); restrictAreaEvent(ev, gr); /* Normalise to area of rec */ send(g, NAME_drag, ev, EAV); synchroniseGraphical(gr, ON); doneObject(ev); } succeed; }
XImage * readImageFile(Image image, IOSTREAM *fd) { unsigned char *data; int w, h; XImage *img=NULL; char hdr[64]; int hdrlen; long offset = Stell(fd); int fmt; hdrlen = Sfread(hdr, 1, sizeof(hdr), fd); Sseek(fd, offset, SIO_SEEK_SET); switch((fmt=image_type_from_data(hdr, hdrlen))) { case IMG_IS_UNKNOWN: case IMG_IS_XBM: case IMG_IS_SUNICON: if ( (data = read_bitmap_data(fd, &w, &h)) != NULL ) return CreateXImageFromData(data, w, h); if ( fmt != IMG_IS_UNKNOWN ) break; #ifdef HAVE_LIBJPEG case IMG_IS_JPEG: switch(staticColourReadJPEGFile(image, fd, &img)) { case IMG_OK: return img; case IMG_NOMEM: return NULL; default: break; } if ( (img=readJPEGFile(image, fd)) ) return img; if ( fmt != IMG_IS_UNKNOWN ) break; #endif #ifdef HAVE_LIBXPM #ifdef O_GIFTOXPM case IMG_IS_GIF: if ( (img=readGIFFile(image, fd)) ) return img; if ( fmt != IMG_IS_UNKNOWN ) break; #endif case IMG_IS_XPM: if ( (img=readXpmFile(image, fd)) ) return img; if ( fmt != IMG_IS_UNKNOWN ) break; #endif default: if ( fmt != IMG_IS_UNKNOWN ) { DEBUG(NAME_image, Cprintf("Image format %d not supported\n", fmt)); } } return NULL; }
static void shiftpts(IPoint pts, int to, int shift) { DEBUG(NAME_bezier, Cprintf("Shift to %d\n", to)); to--; for(; to>=shift; to--) pts[to] = pts[to-shift]; }