Exemplo n.º 1
0
void usersolve() {
    x=5;
    y=6;
    ox=x;
    oy=y;
    steps=0;
    r=1;
    m=0;
    while((x!=width-3) && (button==0)) {
        expose();
        XQueryPointer(display,main_win,&root,&win,&root_x,&root_y,&win_x,&win_y,&mask);
        while(ox!=x || oy!=y) {
            steps++;
            pset(ox,oy,7);
            px[m]=ox;
            py[m]=oy;
            if(m<maxdepth) m++;
            sprintf(status," Steps: %d",steps);
            showstatus(0);
            if(ox!=x) ox=x;
            else oy=y;
        }
        pset(ox,oy,7);
        ox=x;
        oy=y;
        pset(x,y,(fg+1)&31);
        if((x>win_x/mag) && (ppoint(x-1,y)!=bg)) x--;
        if((x<win_x/mag) && (ppoint(x+1,y)!=bg)) x++;
        if((y>win_y/mag) && (ppoint(x,y-1)!=bg)) y--;
        if((y<win_y/mag) && (ppoint(x,y+1)!=bg)) y++;
        nap(50);
    }
    if(x==width-3) {
        code=rand();
        sprintf(status," %d Steps! Code:%04X ",steps,code);
        showstatus(0);
        i=0;
        c=1;
        button=0;
        while(button==0) {
            pset(ox,oy,c);
            ox=px[i];
            oy=py[i];
            pset(ox,oy,0);
            i++;
            if(i>=m) {
                i=0;
                c=(c+1)&31;
                if(c==bg) c=(c+1)&31;
            }
            expose();
            nap(20);
        }
    }
    waitnobutton();
}
Exemplo n.º 2
0
    /**
     * 頂点 @a v を根とする木を頂点 @a w に接続する
     */
    void link(int v, int w){
        node *c = &nodes[v], *p = &nodes[w];
        expose(c);
        expose(p);
        c->pp = p;
        p->cp[R] = c;

        p->dcost += p->dmin - min(p->dmin, c->dmin);
        if(p->cp[L]) p->cp[L]->dmin += p->dmin - min(p->dmin, c->dmin);
        p->dmin = min(p->dmin, c->dmin);
        c->dmin = c->dmin - p->dmin;
    }
Exemplo n.º 3
0
void pset(int x, int y, int color ) {
    scr[x*height+y]=color;
    XSetForeground(display,the_GC,colors[color]);
    XFillRectangle(display,main_pixmap,the_GC,x*mag,y*mag,mag,mag);
    XFillRectangle(display,main_win,the_GC,x*mag,y*mag,mag,mag);
    expose();
}
Exemplo n.º 4
0
	//Initialize the javascript context and expose the methods in exposer
	bool _BeaScript::init()
	{
		
		lastError = "";
		HandleScope handle_scope;

		if (globalTemplate.IsEmpty()){
			globalTemplate = v8::Persistent<v8::ObjectTemplate>::New(createGlobal());
		}
		
		//Create the context
		m_context = v8::Context::New(NULL, globalTemplate);

		Context::Scope context_scope(m_context);

		globalSandbox = v8::Persistent<v8::Object>::New(v8::Object::New()); 

		Handle<Value> vCmdLine = bea::Convert<std::vector<std::string> >::ToJS(cmdLine);

		Handle<Object> objProcess = v8::Object::New();
		objProcess->Set(v8::String::New("argv"), vCmdLine);

		m_context->Global()->Set(v8::String::New("process"), objProcess);
		
		expose();

		executeScript("./loader.js");
		CloneObject(m_context->Global(), globalSandbox);


		return true; 
	}
Exemplo n.º 5
0
static int		one_shot(int keycode, t_mdata *mdata)
{
	if (keycode == ECHAP)
		exit(0);
	else if (keycode == NUM_0 || keycode == NUMPAD_0)
		reset_values(mdata);
	else if (keycode == SPACE)
		mdata->debug = (mdata->debug ? 0 : 1);
	else if (keycode == NUM_1 || keycode == NUMPAD_1)
		mdata->shadows = (mdata->shadows ? 0 : 1);
	else if (keycode == 47)
	{
		mdata->keys->more_angle = (mdata->keys->more_angle ? 0 : 1);
		mdata->keys->less_angle = 0;
	}
	else if (keycode == 46)
	{
		mdata->keys->less_angle = (mdata->keys->less_angle ? 0 : 1);
		mdata->keys->more_angle = 0;
	}
	else
		return (0);
	expose(mdata);
	return (1);
}
Exemplo n.º 6
0
/*
 * Hlavní cyklus zpracování událostí
 */
static void event_loop(void)
{
    XEvent event;
    
    while(1) {
	XNextEvent(display, &event);
	switch(event.type) {
	    case Expose:
		expose(&event.xexpose);
		break;
	    case ButtonPress:
		debug("Button %u pressed\n", event.xbutton.button);
		return;
		break;
	    case ConfigureNotify:
		if((int)topwin_w != event.xconfigure.width ||
		   (int)topwin_h != event.xconfigure.height) {
		    topwin_w = event.xconfigure.width;
		    topwin_h = event.xconfigure.height;
		    debug("Window resized to %ux%u pixels\n",
			  topwin_w, topwin_h);
		    XClearWindow(display, topwin);
		}
		break;
	    case MappingNotify:
		/* Naèíst zmìnìné mapování kláves */
		if(event.xmapping.request == MappingKeyboard)
		    XRefreshKeyboardMapping(&event.xmapping);
		break;
	    default:
		/* Zbylé nezajímavé události */
		break;
	}
    }
}
Exemplo n.º 7
0
static void notify_act(Widget w, XEvent *event, String *params, Cardinal *n)
{
  CtrlWidget cw = (CtrlWidget)w;
  CtrlPart *c = & cw->ctrl;  
  TF();

  if( ! c->isflip ) {
    c->msg.cmd = MSG_FIRE;
    XtCallCallbacks( w, XtNcallback, (XtPointer) & c->msg );
  }
  else {
    if( c->msg.state == STATE_ARMED ) {
      c->msg.state = STATE_SELECTED;
      c->msg.cmd = MSG_FIRE;
      XtCallCallbacks( w, XtNcallback, (XtPointer) & c->msg );
    }
    else {
      c->msg.state = STATE_ARMED;
      /* make virtual keyboard visible */
      vis_setup_slider_t msg;
      msg.min = c->msg.min_value;
      msg.max = c->msg.max_value;
      msg.cur = c->msg.value;
      sig_send( w, VIS_SETUP_SLIDER, &msg );
    }
  }

  expose(w, NULL, 0);
}
Exemplo n.º 8
0
void	*end_meet(void *param)
{
	int		current_time;
	t_data	*philo;
	int		i;

	current_time = time(NULL);
	philo = param;
	while (time(NULL) < current_time + TIMEOUT)
	{
		i = -1;
		while (++i < 7)
		{
			if (philo[i].sticks->action[i] != 2)
				philo[i].sticks->life[i]--;
			if (!check_alive(philo[i], &i))
				break ;
		}
		expose(philo[0].sticks);
		usleep(1000000);
		if (i == -1)
			break ;
	}
	if (i == -1)
		return (NULL);
	ft_putendl("Now, it is time... To DAAAAAAAANCE !!!");
	return (NULL);
}
Exemplo n.º 9
0
/*
 * Hlavní cyklus zpracování událostí
 */
static void event_loop(void)
{
    XEvent event;
    char buf[10];
    KeySym keysym;

    while(1) {
        XNextEvent(display, &event);
        switch(event.type) {
        case Expose:
            expose(&event.xexpose);
            break;
        case ButtonPress:
            debug("Button %u pressed\n", event.xbutton.button);
            return;
            break;
        case KeyPress:
            XLookupString(&event.xkey, buf, 10, &keysym, NULL);
            debug("Key \"%s\" pressed\n", XKeysymToString(keysym));
            return;
            break;
        case MappingNotify:
            /* Naèíst zmìnìné mapování kláves */
            if(event.xmapping.request == MappingKeyboard)
                XRefreshKeyboardMapping(&event.xmapping);
            break;
        default:
            /* Zbylé nezajímavé události */
            break;
        }
    }
}
Exemplo n.º 10
0
void initscreen(void) {
    screen(width,height);
    color(fg,bg);
    expose();
    pcls(bg);
    clearstatus();
    box(4,4,width-4,height-4,fg);
}
Exemplo n.º 11
0
void QtBuiltins::add(jx::Ob * node) {

  jx_ob names = jx_hash_new();
  jx_code_expose_secure_builtins(names);
  expose(names);
  jx_hash_set(node->ob(), jx_builtins(), jx_ob_copy(names));
  jx_ob_free(names);
}
Exemplo n.º 12
0
bool
TopWindow::on_event(const SDL_Event &event)
{
  switch (event.type) {
    Window *w;

  case SDL_VIDEOEXPOSE:
    invalidated_lock.Lock();
    invalidated = false;
    invalidated_lock.Unlock();

    expose();
    return true;

  case SDL_KEYDOWN:
    w = get_focused_window();
    if (w == NULL)
      w = this;

    return w->on_key_down(event.key.keysym.sym);

  case SDL_KEYUP:
    w = get_focused_window();
    if (w == NULL)
      w = this;

    return w->on_key_up(event.key.keysym.sym);

  case SDL_MOUSEMOTION:
    // XXX keys
    return on_mouse_move(event.motion.x, event.motion.y, 0);

  case SDL_MOUSEBUTTONDOWN:
    if (event.button.button == SDL_BUTTON_WHEELUP)
      return on_mouse_wheel(event.button.x, event.button.y, 1);
    else if (event.button.button == SDL_BUTTON_WHEELDOWN)
      return on_mouse_wheel(event.button.x, event.button.y, -1);

    static PeriodClock double_click;
    return double_click.check_always_update(300)
      ? on_mouse_down(event.button.x, event.button.y)
      : on_mouse_double(event.button.x, event.button.y);

  case SDL_MOUSEBUTTONUP:
    if (event.button.button == SDL_BUTTON_WHEELUP ||
        event.button.button == SDL_BUTTON_WHEELDOWN)
      /* the wheel has already been handled in SDL_MOUSEBUTTONDOWN */
      return false;

    return on_mouse_up(event.button.x, event.button.y);

  case SDL_QUIT:
    return on_close();
  }

  return false;
}
Exemplo n.º 13
0
void Text::location(unsigned line, unsigned column) 
{
	TextLocation old = insertion_;
	insertion_.line_ = line;
	insertion_.column_ = column;
	damage(old);
	damage(insertion_);
	expose(line, column);
}
Exemplo n.º 14
0
inline void register_value_type(TPythonClass &pyClass){ 
    typedef details::pair_exposer_t< TValueType, TValueCallPolicies > exposer_type;
    
    object class_name(pyClass.attr("__name__"));
    extract<std::string> class_name_extractor(class_name);
    std::string pair_name = class_name_extractor() + "_entry";
    
    exposer_type expose( pair_name );
}
Exemplo n.º 15
0
static void highlight_act(Widget w, XEvent* e, String* s, Cardinal* n)
{
  CtrlWidget cw = (CtrlWidget)w;
  CtrlPart *c = & cw->ctrl;  
  TF();
  if( c->msg.state == STATE_SELECTED ) return;
  c->msg.state = STATE_SELECTED;
  expose(w, NULL, 0);
}
Exemplo n.º 16
0
static void reset_act(Widget w, XEvent* e, String* s, Cardinal* n)
{
  CtrlWidget cw = (CtrlWidget)w;
  CtrlPart *c = & cw->ctrl;  
  TF();
  if( c->msg.state == STATE_NORMAL ) return;
  c->msg.state = STATE_NORMAL;
  expose(w, NULL, 0);
  /* disable virtual keyboard */
  sig_send( w, VIS_REMOVE_SLIDER, NULL  ); 
}
Exemplo n.º 17
0
    /**
     * 木を頂点 @a v から親に向かう辺を削除することで2つの木に分ける
     */
    void cut(int v){
        node *c = &nodes[v];
        expose(c);
        node *p = c -> cp[L];
        c->cp[L] = NULL;
        p->pp = NULL;

        p->dmin += c->dmin;
        c->dmin += c->dcost;
        c->dcost = 0;
    }
Exemplo n.º 18
0
gpointer
x_view_display (gpointer instance,
		gpointer surface,
		gpointer win,
		int      width,
		int      height,
		gpointer state)
{
  XViewer *x = (XViewer *) instance;
  Pixmap pixmap = (Pixmap) surface;
  Window window = (Window) win;
  XEvent xev;
  XRectangle  r;
  Region update_region;
  unsigned int quit_keycode;
  unsigned int borders_keycode;
  gboolean show_borders = FALSE;

  if (state)
    show_borders = GPOINTER_TO_UINT (state) == 0xdeadbeef;

  /* force a full redraw */
  update_region = XCreateRegion ();
  r.x = 0;
  r.y = 0;
  r.width = width;
  r.height = height;
  XUnionRectWithRegion (&r, update_region, update_region);

  borders_keycode = XKeysymToKeycode(x->display, 'B');
  quit_keycode = XKeysymToKeycode(x->display, 'Q');

  while (1)
    {
      if (!XPending (x->display) && update_region)
	update (x->display, pixmap, window, &update_region);
	
      XNextEvent (x->display, &xev);
      switch (xev.xany.type) {
      case KeyPress:
	if (xev.xkey.keycode == quit_keycode)
	  return NULL;
	else if (xev.xkey.keycode == borders_keycode)
	  {
	    show_borders = !show_borders;
	    return GUINT_TO_POINTER (show_borders ? 0xdeadbeef : 0xbe);
	  }
	break;
      case Expose:
	expose (&xev.xexpose, &update_region);
	break;
      }
    }
}
Exemplo n.º 19
0
  void update() {
    //assert_none_locked();

#ifdef ENABLE_SDL
    // XXX
    expose();
#else /* !ENABLE_SDL */
    ::UpdateWindow(hWnd);
    // duplicate in MainWindow
#endif /* !ENABLE_SDL */
  }
Exemplo n.º 20
0
 /**
  * 頂点 @a n から根に向かうパスの中で最小の重みと,その重みをもつ頂点のうち最も根に近い頂点の組を返す
  * @return (重み最小の頂点,重み最大の頂点)
  */
 pair<int, int> findcost(int n){
     node *v = expose(&nodes[n]);
     for(;;){
         v->push();
         if(v->cp[L] && v->cp[L]->dmin == 0) v = v->cp[L];
         else if((!v->cp[L] || v->cp[L]->dmin > 0) && v->dcost > 0) v = v->cp[R];
         else break;
     }
     v->splay();
     return make_pair(v->dmin, v->id);
 }
Exemplo n.º 21
0
void Text::region(unsigned line1, unsigned column1,
	unsigned line2, unsigned column2) 
{
	TextRegion old = selection_;
	selection_.line1(line1);
	selection_.column1(column1);
	selection_.line2(line2);
	selection_.column2(column2);
	damage(old);
	damage(selection_);
	expose(line1, column1, line2, column2);
}
Exemplo n.º 22
0
void	draw_the_pit(t_ole *t)
{
  int	i;

  i = 0;
  my_draw_arc(t->img, W / 10 - 2, COLOR_PIT, t);
  my_draw_arc(t->img, W / 10 - 1, COLOR_PIT, t);
  my_draw_arc(t->img, W / 10 - 0, COLOR_PIT, t);
  my_draw_arc(t->img, W / 10 + 1, COLOR_PIT, t);
  my_draw_arc(t->img, W / 10 + 2, COLOR_PIT, t);
  my_get_hitbox(t->img, t);
  expose(t);
}
Exemplo n.º 23
0
int EMSCRIPTEN_KEEPALIVE setscreensize(int yes)
{
    int w, h, f;

    emscripten_get_canvas_size(&w, &h, &f);
    if (1 || f == 0) {
	w = emscripten_run_script_int("window.innerWidth");
	h = emscripten_run_script_int("window.innerHeight");
	emscripten_set_canvas_size(w, h);
    }

    expose();
    return yes;
}
Exemplo n.º 24
0
void GTKGeomWindow::field_diag( int action, double x, double y )
{
    int x0, y0, width = 0, height = 0;

    if( action == 0 ) {
	// Start
	_start[0] = _end[0] = (int)floor(x+0.5);
	_start[1] = _end[1] = (int)floor(y+0.5);

    } else if( action == 1 || action == 2 ) {
	// Erase old line
	x0 = _start[0] < _end[0] ? _start[0] : _end[0];
	y0 = _start[1] < _end[1] ? _start[1] : _end[1];
	width = abs( _start[0] - _end[0] );
	height = abs( _start[1] - _end[1] );
	expose( x0-1, y0-1, width+3, height+3 );
    }

    if( action == 1 ) {
	// Draw new line
	_end[0] = (int)floor(x+0.5);
	_end[1] = (int)floor(y+0.5);
	cairo_t *cairo = gdk_cairo_create( gtk_widget_get_window( _darea ) );
	cairo_move_to( cairo, _start[0], _start[1] );
	cairo_line_to( cairo, _end[0], _end[1] );
	cairo_set_source_rgb( cairo, 0, 0, 0 );
	cairo_set_line_width( cairo, 1.0 );
	cairo_stroke( cairo );
	cairo_destroy( cairo );

    } else if( action == 2 ) {
	// Done, start field diagnostics dialog
	Coordmapper cm = _frame.get_coordmapper( PLOT_AXIS_X1, PLOT_AXIS_Y1 );
	double x1[2] = {(double)_start[0], (double)_start[1]};
	double x2[2] = {(double)_end[0], (double)_end[1]};
	cm.inv_transform( x1[0], x1[1] );
	cm.inv_transform( x2[0], x2[1] );
	double p1[3];
	double p2[3];
	p1[_geomplot.vb(0)] = x1[0];
	p2[_geomplot.vb(0)] = x2[0];
	p1[_geomplot.vb(1)] = x1[1];
	p2[_geomplot.vb(1)] = x2[1];
	p1[_geomplot.vb(2)] = _geomplot.get_level_si();
	p2[_geomplot.vb(2)] = _geomplot.get_level_si();
	GTKFieldDiagDialog fielddiag( _window, _plotter, p1, p2 );
	fielddiag.run();
    }
}
Exemplo n.º 25
0
void filledbox(int xx1, int yy1, int x2, int y2, int color) {
    int i,j,x,y,w,h;
    x=xx1<x2?xx1:x2;
    y=yy1<y2?yy1:y2;
    w=abs(x2-xx1);
    h=abs(y2-yy1);
    XSetForeground(display,the_GC,colors[color]);
    XFillRectangle(display,main_pixmap,the_GC,x*mag,y*mag,w*mag,h*mag);
    XFillRectangle(display,main_win,the_GC,x*mag,y*mag,w*mag,h*mag);
    expose();
    for(i=x; i<=(x+w); i++) {
        for(j=y; j<=(y+h); j++) {
            scr[i*height+j]=color;
        }
    }
}
Exemplo n.º 26
0
void box(int xx1, int yy1, int x2, int y2, int color) {
    int i,x,y,w,h;
    x=xx1<x2?xx1:x2;
    y=yy1<y2?yy1:y2;
    w=abs(x2-xx1);
    h=abs(y2-yy1);
    for(i=x; i<=x+w; i++) {
        pset(i,y,color);
        pset(i,y+h,color);
    }
    for(i=y; i<=y+h; i++) {
        pset(x,i,color);
        pset(x+w,i,color);
    }
    expose();
}
Exemplo n.º 27
0
void
mag_release(XEvent * event)
{
    UNUSED(event);
    if (magnifier.win != (Window) 0) {
	if (magnifier_stat) {
	    magnifier_stat = -1;	/* destroy upon expose */
	}
	else {
	    XDestroyWindow(DISP, magnifier.win);
	    if (drawing_mag) {
		globals.ev.flags |= EV_MAG_GONE;
	    }
	    magnifier.win = (Window) 0;
	    mouse_motion = mouse_release = null_mouse;
	    globals.ev.flags &= ~EV_MAG_MOVE;
	    globals.cursor.flags &= ~CURSOR_MAG;
	    globals.ev.flags |= EV_CURSOR;
	    can_exposures(&magnifier);
	    /*
	      Workaround for bug #703304:
	      For obscure reasons, XFree 3.3.5 (and apparently also Solaris 8)
	      doesn't generate an expose event after the magnifier has beed
	      destroyed. But only a redraw() event caused by expose would reset
	      currwin.win back to mane.win, which is needed e.g. for getting the
	      hyperlink info updated (otherwise, the mouse will not become active
	      over a hyperlink).

	      Forcing a redraw with
	      redraw(&mane);
	      may cause a `BadDrawable' X error with color material (e.g. from #702288),
	      or a `draw_part: shouldn't happen: POST encountered' error. Neither do
	      the following work:
	      globals.ev.flags |= EV_EXPOSE;		(doesn't fix the bug)
	      draw_page();			(same effect as redraw(&mane))
	      globals.ev.flags |= EV_NEWPAGE;	(works, but is crude and causes flicker)
		 
	      So I decided to use expose() for the time being, which 
	      sets mane.min_x to the current x point (which doesn't happen
	      with EV_EXPOSE; this causes the test for `mane.min_x < MAXDIM'
	      to fail in events.c; look for `see comment in mag.c').
	    */
	    /*  	    fprintf(stderr, "========triggering expose!\n"); */
	    expose(&mane, event->xbutton.x_root, event->xbutton.y_root, 10, 10);
	}
    }
}
Exemplo n.º 28
0
Arquivo: Sash.c Projeto: att/uwin
static void
SashAction(Widget w,
	   XEvent *event,
	   String *params,
	   Cardinal *num_params)
{
    XmSashWidget sw = (XmSashWidget)w;
    SashCallDataRec cd;

    cd.event = event;
    cd.params = params;
    cd.num_params = *num_params;

    XtCallCallbackList((Widget)sw, Sash_SashAction(sw), &cd);

    expose(w, NULL, NULL);
}
Exemplo n.º 29
0
void
TopWindow::refresh()
{
#ifdef ANDROID
  if (resumed) {
    /* Try to reinitialize OpenGL.  This often fails on the first
       attempt (IllegalArgumentException "Make sure the SurfaceView or
       associated SurfaceHolder has a valid Surface"), therefore we're
       trying again until we're successful. */

    assert(paused);

    if (!native_view->initSurface())
      /* failed - retry later */
      return;

    paused = false;
    resumed = false;

    screen.Set();

    SurfaceCreated();

    if (resized) {
      resized = false;
      resize(new_width, new_height);
    }
  }

  if (paused || !surface_valid)
    /* the application is paused/suspended, and we don't have an
       OpenGL surface - ignore all drawing requests */
    return;
#endif

  invalidated_lock.Lock();
  if (!invalidated) {
    invalidated_lock.Unlock();
    return;
  }

  invalidated = false;
  invalidated_lock.Unlock();

  expose();
}
Exemplo n.º 30
0
void	erase_ball(t_ole *t, int ball)
{
  int	i;
  int	j;

  i = 0;
  while (i < S_BALL)
    {
      j = 0;
      while (j < S_BALL)
	{
	  my_pixel_put_image(t->img, t->oball[ball] % W + i, t->oball[ball] / W + j, COLOR_BG);
	  j = j + 1;
	}
      i = i + 1;
    }
  expose(t);
}