コード例 #1
0
ファイル: menu.c プロジェクト: S010/cwm
static void
menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
    struct menu_q *resultq)
{
	struct menu		*mi;
	XineramaScreenInfo	*xine;
	int			 xmin, xmax, ymin, ymax;
	int			 n, dy, xsave, ysave;
	int			 bwidth2;
	XftColor		*xftcolorp = &sc->xftcolor;

	if (mc->list) {
		if (TAILQ_EMPTY(resultq) && mc->list) {
			/* Copy them all over. */
			TAILQ_FOREACH(mi, menuq, entry)
				TAILQ_INSERT_TAIL(resultq, mi,
				    resultentry);

			mc->listing = 1;
		} else if (mc->changed)
			mc->listing = 0;
	}

	mc->num = 0;
	mc->width = 0;
	dy = 0;
	if (mc->hasprompt) {
		(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s",
		    mc->promptstr, mc->searchstr, PROMPT_ECHAR);
		mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr));
		dy = font_height(sc);
		mc->num = 1;
	}

	TAILQ_FOREACH(mi, resultq, resultentry) {
		char *text;

		if (mc->print != NULL) {
			(*mc->print)(mi, mc->listing);
			text = mi->print;
		} else {
			mi->print[0] = '\0';
			text = mi->text;
		}

		mc->width = MAX(mc->width, font_width(sc, text,
		    MIN(strlen(text), MENU_MAXENTRY)));
		dy += font_height(sc);
		mc->num++;
	}
コード例 #2
0
/* Show some lines of text (during the game). */
struct widget * widget_new_game_window(char ** lines, int lines_count)
{
  int width, height;
  int x, y;

  width = 10;
  for(int i = 0; i < lines_count; i++)
    {
      int w;

      w = font_width(lines[i]);
      if(w > width)
        width = w;
    }
  width += 20;

  height = (2 + lines_count) * font_height();

  x = (SCREEN_WIDTH - width) / 2;
  y = (SCREEN_HEIGHT - height) / 2;

  struct widget * window;

  window = widget_new_frame(widget_root(), x, y, width, height);
  assert(window != NULL);

  widget_delete_flags(window, WF_DRAW_BORDERS | WF_CAST_SHADOW);
  widget_set_ulong(window, "alpha", 0xc0);

  for(int i = 0; i < lines_count; i++)
    widget_new_text(window, 10, (1 + i) * font_height(), lines[i]);

  return window;
}
コード例 #3
0
struct widget * widget_new_text(struct widget * parent, int x, int y, char const * const text)
{
  struct widget * obj;
  int w, h;

  if(text != NULL)
    {
      w = 2 + font_width(text) + 2;
      h = 1 + font_height() + 1;
    }
  else
    {
      w = 4;
      h = 4;
    }
  obj = widget_new_child(parent, x, y, w, h);
  assert(obj != NULL);
  if(obj != NULL)
    {
      widget_set_on_draw(obj, widget_draw);
      widget_set_ulong(obj, "type", WT_TEXT);
      widget_set_flags(obj, 0);

      if(text != NULL)
        widget_set_string(obj, "text", "%s", text);
    }

  return obj;
}
コード例 #4
0
ファイル: pdfglyph.c プロジェクト: live-clones/luatex
static void setup_fontparameters(PDF pdf, internal_font_number f, int ex_glyph)
{
    float slant, extend, squeeze, expand, scale = 1.0;
    float u = 1.0;
    pdfstructure *p = pdf->pstruct;
    if ((font_format(f) == opentype_format || (font_format(f) == type1_format && font_encodingbytes(f) == 2))  && font_units_per_em(f) > 0)
        u = font_units_per_em(f) / 1000.0;
    pdf->f_cur = f;
    p->f_pdf = pdf_set_font(pdf, f);
    p->fs.m = i64round(font_size(f) / u / by_one_bp * ten_pow[p->fs.e]);
    slant = font_slant(f) / 1000.0;
    extend = font_extend(f) / 1000.0;
    squeeze = font_squeeze(f) / 1000.0;
    expand = 1.0 + (ex_glyph/1) / 1000.0;
    /*tex The |-1| makes less corrections inside |[]TJ|: */
    p->tj_delta.e = p->cw.e - 1;
    /*tex There is no need to be more precise than \TEX\ (1sp). */
    while (p->tj_delta.e > 0 && (double) font_size(f) / ten_pow[p->tj_delta.e + e_tj] < 0.5) {
        /*tex This happens for very tiny fonts. */
        p->tj_delta.e--;
    }
    p->tm[0].m = i64round(scale * expand * extend * ten_pow[p->tm[0].e]);
    p->tm[2].m = i64round(slant * ten_pow[p->tm[2].e]);
    p->tm[3].m = i64round(scale * squeeze * ten_pow[p->tm[3].e]);
    p->k2 = ten_pow[e_tj + p->cw.e] * scale / (ten_pow[p->pdf.h.e] * pdf2double(p->fs) * pdf2double(p->tm[0]));
    /*tex We keep track of the state of ex. */
    p->cur_ex = ex_glyph ;
    p->need_width = font_width(f);
    p->need_mode = font_mode(f);
}
コード例 #5
0
ファイル: quartzWindow.cpp プロジェクト: ardeujho/self
void QuartzWindow::draw_text(const char* text, int x, int y)  { 
  int len = strlen(text);
  int h = font_height();
  
  clear_rectangle(x, y-h, len * font_width(), h);
  CGContextSetTextPosition(myContext, x, y);
  CGContextShowText(myContext, text, len);
} 
コード例 #6
0
int createconsole(int argc, char *argv[])
{
  if (win != NULL)
    return 1;

  if (app != NULL)      /* delete existing partial data structures */
    deleteconsole();

  lines = malloc(NUM_LINES*NUM_COLUMNS*sizeof(TCHAR));
  if (lines == NULL)
    return 0;
  memset(lines, __T(' '), NUM_LINES * NUM_COLUMNS);

  app = new_app(argc, argv);
  if (app == NULL) {
    deleteconsole();
    return 0;
  } /* if */

  font = new_font(app, "unifont", PLAIN | PORTABLE_FONT, 16);
  if (font == NULL)
    font = new_font(app, "courier", PLAIN | NATIVE_FONT, 16);
  if (font == NULL)
    font = find_default_font(app);
  if (font == NULL) {
    deleteconsole();
    return 0;
  } /* if */

  win = new_window(app,
                   rect(0,0,
                        NUM_COLUMNS*font_width(font,"x",1),
                        NUM_LINES*font_height(font)),
                   "Pawn console",
                   TITLEBAR|CLOSEBOX|MAXIMIZE|MINIMIZE|CENTRED);
  on_window_redraw(win, window_redraw);
  on_window_close (win, window_close);
  on_window_key_down(win, window_key_action);     /* normal keys (including CR) */
  show_window(win);

  /* handle any pending events */
  while (do_event(app))
    /* nothing */;

  csrx = 0;
  csry = 0;
  autowrap = 0;
  attrib = 0x07;

  return 1;
}
コード例 #7
0
ファイル: term_ga.c プロジェクト: ATrigger/ruspawncc
/* dx = in columns, dy = in lines */
void scroll_window(int dx, int dy)
{
  Graphics *g;
  Rect r;
  Point p;

  /* a negative value scrolls up */
  assert(lines != NULL);
  if (dy < 0) {
    assert(-dy < NUM_LINES);
    memmove(lines,lines-dy*NUM_COLUMNS,(NUM_LINES+dy)*NUM_COLUMNS*sizeof(TCHAR));
    memset(lines+(NUM_LINES+dy)*NUM_COLUMNS*sizeof(TCHAR), __T(' '), -dy*NUM_COLUMNS);
  } else if (dy > 0) {
    assert(dy < NUM_LINES);
    memmove(lines+dy*NUM_COLUMNS,lines,(NUM_LINES-dy)*NUM_COLUMNS*sizeof(TCHAR));
    memset(lines, __T(' '), dy*NUM_COLUMNS);
  } /* if */
  csry += dy;
  if (csry < 0)
    csry = 0;
  if (csry >= NUM_LINES)
    csry=NUM_LINES - 1;

  assert(font != NULL);
  dx *= font_width(font, "x", 1);
  dy *= font_height(font);

  g = get_window_graphics(win);
  r = get_window_area(win);
  p = pt(r.x + dx, r.y + dy);
  copy_rect(g, p, g, r);
  if (dy > 0) {
    /* moving window contents downwards */
    redraw_rect(win, rect(0,0,r.width,dy));
  } else if (dy < 0) {
    /* moving window contents upwards */
    redraw_rect(win, rect(0,r.height+dy,r.width,0-dy));
  } /* if */
  if (dx > 0) {
    /* moving window contents to the right */
    redraw_rect(win, rect(0,0,dx,r.height));
  } else if (dx < 0) {
    /* moving window contents to the left */
    redraw_rect(win, rect(r.width+dx,0,0-dx,r.height));
  } /* if */
  del_graphics(g);
}
コード例 #8
0
ファイル: keymingler.c プロジェクト: JINXSHADYLANE/quibble
int dgreed_main(int argc, const char** argv) {
	params_init(argc, argv);
	rand_init(time(NULL));
	layouts_init();
	layouts_set("dvorak");

	bool fullscreen = true;
	if(params_find("-windowed") != ~0)
		fullscreen = false;

	video_init_ex(SCREEN_WIDTH, SCREEN_HEIGHT, 
		SCREEN_WIDTH, SCREEN_HEIGHT, "KeyMingler", fullscreen);
	font = font_load(FONT_FILE);	
	float text_width = font_width(font, LOADING_TEXT);
	float text_height = font_height(font);
	Vector2 pos = vec2((SCREEN_WIDTH - text_width) / 2.0f,
		(SCREEN_HEIGHT - text_height) / 2.0f);
	font_draw(font, LOADING_TEXT, 0, &pos, COLOR_WHITE);	
	video_present();
	system_update();

	game_init();
	sounds_init();
	music = sound_load_stream(MUSIC_FILE);
	sound_play(music);

	while(system_update()) {
		game_update();
		game_render();
		video_present();
		sound_update();

		if(key_up(KEY_QUIT))
			break;
	}
	
	font_free(font);
	sound_free(music);
	sounds_close();
	game_close();
	video_close();
	layouts_close();

	return 0;
}
コード例 #9
0
ファイル: edit.c プロジェクト: jff/mathspad
static int edit_margin(void *data)
{
    EDITINFO *einf = (EDITINFO *) data;

    einf->empty = window_empty(einf->info);
    if (!einf->view_mode && !einf->shell) {
	if (!einf->auto_saved)
	    einf->auto_saved = einf->empty;
	else if (change_check)
	    einf->auto_saved = !window_changed(einf->info) || einf->empty;
	if ((!einf->auto_saved && einf->saved) || 
	    (!einf->saved && einf->empty)) {
	    einf->saved = !einf->saved;
	    set_name(einf, einf->pathname);
	}
    }
    return -scrollbar_line(einf->scrollhor, 0) * font_width() + 3;
}
コード例 #10
0
ファイル: puzzle.c プロジェクト: Gelma/xlockmore-for-13.04
static Bool
NumberScreen(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	puzzlestruct *pp = &puzzles[MI_SCREEN(mi)];

	if (mode_font == None)
		mode_font = getFont(display);
	if (!pp->done) {
		XGCValues   gcv;

		pp->done = 1;
		gcv.font = mode_font->fid;
		gcv.graphics_exposures = False;
		gcv.foreground = MI_WHITE_PIXEL(mi);
		gcv.background = MI_BLACK_PIXEL(mi);
		if ((pp->gc = XCreateGC(display, window,
				GCForeground | GCBackground | GCGraphicsExposures | GCFont,
				&gcv)) == None) {
			free_puzzle(display, pp);
			return False;
		}
		pp->ascent = mode_font->ascent;
		pp->fontHeight = font_height(mode_font);
		pp->fontWidth = font_width(mode_font, '5');
	}
	XSetForeground(display, pp->gc, MI_WHITE_PIXEL(mi));

	{
		XPoint      pos, letter;
		int         count = 1, digitOffset = 1, temp, letterOffset;
		int         i, j, mult = pp->count.x * pp->count.y;
		char        buf[16];

		letter.x = pp->boxsize.x / 2 - 3;
		letter.y = pp->boxsize.y / 2 + pp->ascent / 2 - 1;
		letterOffset = pp->fontWidth / 2;
		pos.y = 0;
		for (j = 0; j < pp->count.y; j++) {
			pos.x = 0;
			for (i = 0; i < pp->count.x; i++) {
				if (count < mult) {
					if (pp->boxsize.x > 2 * pp->fontWidth &&
					    pp->boxsize.y > pp->fontHeight) {
						(void) sprintf(buf, "%d", count);
						(void) XDrawString(display, window, pp->gc,
								   pos.x + letter.x - letterOffset * digitOffset +
							     pp->randompos.x,
								   pos.y + letter.y + pp->randompos.y, buf, digitOffset);
					}
					XDrawRectangle(display, window, pp->gc,
						       pos.x + 1 + pp->randompos.x, pos.y + 1 + pp->randompos.y,
					pp->boxsize.x - 3, pp->boxsize.y - 3);
					count++;
					digitOffset = 0;
					temp = count;
					while (temp >= 1) {
						temp /= 10;
						digitOffset++;
					}
				}
				pos.x += pp->boxsize.x;
			}
			pos.y += pp->boxsize.y;
		}
	}
	return True;
}
コード例 #11
0
/* calcula la longitud de la cadena en puntos segun la resolucion */
long double string_width(const string& str)
{
  return compute_true_len(str)*font_width();
}
コード例 #12
0
ファイル: marquee.c プロジェクト: Gelma/xlockmore-for-13.04
void
init_marquee(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	marqueestruct *mp;
	XGCValues   gcv;
	int         i;

	if (marquees == NULL) {
		if ((marquees = (marqueestruct *) calloc(MI_NUM_SCREENS(mi),
					    sizeof (marqueestruct))) == NULL)
			return;
	}
	mp = &marquees[MI_SCREEN(mi)];

	mp->win_width = MI_WIDTH(mi);
	mp->win_height = MI_HEIGHT(mi);
	if (MI_NPIXELS(mi) > 2)
		mp->color = NRAND(MI_NPIXELS(mi));
	mp->time = 0;
	mp->t = 0;
	mp->nonblanks = 0;
	mp->x = 0;

	MI_CLEARWINDOW(mi);

	if (mode_font == None)
		mode_font = getFont(display);
	if (mp->gc == NULL && mode_font != None) {
		gcv.font = mode_font->fid;
		gcv.graphics_exposures = False;
		gcv.foreground = MI_WHITE_PIXEL(mi);
		gcv.background = MI_BLACK_PIXEL(mi);
		if ((mp->gc = XCreateGC(display, MI_WINDOW(mi),
				GCForeground | GCBackground | GCGraphicsExposures | GCFont,
				&gcv)) == None) {
			return;
		}
		mp->ascent = mode_font->ascent;
		mp->height = font_height(mode_font);
		for (i = 0; i < 256; i++)
			if ((i >= (int) mode_font->min_char_or_byte2) &&
			    (i <= (int) mode_font->max_char_or_byte2))
				char_width[i] = font_width(mode_font, (char) i);
			else
				char_width[i] = font_width(mode_font, (char) mode_font->default_char);
	} else if (mode_font == None) {
		for (i = 0; i < 256; i++)
			char_width[i] = 8;
	}
	mp->words = fixup_back(getWords(MI_SCREEN(mi), MI_NUM_SCREENS(mi)));
	mp->y = 0;

	if (isRibbon()) {
		mp->x = mp->win_width;
		if (mp->win_height > font_height(mode_font))
			mp->y += NRAND(mp->win_height - font_height(mode_font));
		else if (mp->win_height < font_height(mode_font))
			mp->y -= NRAND(font_height(mode_font) - mp->win_height);
	} else {
		int         text_ht = text_height(mp->words);
		int         text_font_wid = text_font_width(mp->words);

		if (mp->win_height > text_ht * font_height(mode_font))
			mp->y = NRAND(mp->win_height - text_ht * font_height(mode_font));
		if (mp->y < 0)
			mp->y = 0;
		mp->x = 0;
		if (mp->win_width > text_font_wid)
			mp->x += NRAND(mp->win_width - text_font_wid);
		/* else if (mp->win_width < text_font_wid)
		   mp->x -= NRAND(text_font_wid - mp->win_width); */
		mp->startx = mp->x;
	}
}
コード例 #13
0
ファイル: menu.c プロジェクト: S010/cwm
struct menu *
menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
    char *initial, int dummy,
    void (*match)(struct menu_q *, struct menu_q *, char *),
    void (*print)(struct menu *, int))
{
	struct menu_ctx		 mc;
	struct menu_q		 resultq;
	struct menu		*mi = NULL;
	XEvent			 e;
	Window			 focuswin;
	int			 evmask, focusrevert;
	int			 xsave, ysave, xcur, ycur;

	TAILQ_INIT(&resultq);

	bzero(&mc, sizeof(mc));

	xu_ptr_getpos(sc->rootwin, &mc.x, &mc.y);

	xsave = mc.x;
	ysave = mc.y;

	if (prompt == NULL) {
		evmask = MENUMASK;
		mc.promptstr[0] = '\0';
		mc.list = 1;
	} else {
		evmask = MENUMASK | KEYMASK; /* only accept keys if prompt */
		(void)snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%s",
		    prompt, PROMPT_SCHAR);
		(void)snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%s",
		    mc.promptstr, mc.searchstr, PROMPT_ECHAR);
		mc.width = font_width(sc, mc.dispstr, strlen(mc.dispstr));
		mc.hasprompt = 1;
	}

	if (initial != NULL)
		(void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
	else
		mc.searchstr[0] = '\0';

	mc.match = match;
	mc.print = print;
	mc.entry = mc.prev = -1;

	XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width,
	    font_height(sc));
	XSelectInput(X_Dpy, sc->menuwin, evmask);
	XMapRaised(X_Dpy, sc->menuwin);

	if (xu_ptr_grab(sc->menuwin, MENUGRABMASK, Cursor_question) < 0) {
		XUnmapWindow(X_Dpy, sc->menuwin);
		return (NULL);
	}

	XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
	XSetInputFocus(X_Dpy, sc->menuwin, RevertToPointerRoot, CurrentTime);

	/* make sure keybindings don't remove keys from the menu stream */
	XGrabKeyboard(X_Dpy, sc->menuwin, True,
	    GrabModeAsync, GrabModeAsync, CurrentTime);

	menu_draw(sc, &mc, menuq, &resultq);

	for (;;) {
		mc.changed = 0;

		XWindowEvent(X_Dpy, sc->menuwin, evmask, &e);

		switch (e.type) {
		case KeyPress:
			if ((mi = menu_handle_key(&e, &mc, menuq, &resultq))
			    != NULL)
				goto out;
			/* FALLTHROUGH */
		case Expose:
			menu_draw(sc, &mc, menuq, &resultq);
			break;
		case MotionNotify:
			menu_handle_move(&e, &mc, &resultq, sc);
			break;
		case ButtonRelease:
			if ((mi = menu_handle_release(&e, &mc, sc, &resultq))
			    != NULL)
				goto out;
			break;
		default:
			break;
		}
	}
out:
	if (dummy == 0 && mi->dummy) { /* no mouse based match */
		xfree(mi);
		mi = NULL;
	}

	XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
	/* restore if user didn't move */
	xu_ptr_getpos(sc->rootwin, &xcur, &ycur);
	if (xcur == mc.x && ycur == mc.y)
		xu_ptr_setpos(sc->rootwin, xsave, ysave);
	xu_ptr_ungrab();

	XUnmapWindow(X_Dpy, sc->menuwin);
	XUngrabKeyboard(X_Dpy, CurrentTime);

	return (mi);
}
コード例 #14
0
ファイル: edit.c プロジェクト: jff/mathspad
void edit_open(void)
{
    int x = INTERSPACE;
    int y = INTERSPACE;
    unsigned int w=4,h=4;
    int i;
    XSizeHints size_hints;
    EDITINFO *einf;

    state_window = NULL;
    if ( (einf = (EDITINFO *) malloc( sizeof(EDITINFO) )) == NULL)
	message(MP_ERROR, translate("Out of memory in edit."));
    else {
	if (!state_open)
	    if (!last_xpos && !last_ypos) {
		last_xpos = (display_width - last_width)/2;
		last_ypos = (display_height - last_height)/2;
	    }
	einf->xpos = last_xpos;
	einf->ypos = last_ypos;
	einf->width = last_width;
	einf->height = last_height;
	einf->saved = MP_True;
	einf->auto_saved = MP_True;
	einf->view_mode = MP_False;
	einf->empty = MP_True;
	einf->iconized  = MP_True;
	einf->shell = MP_False;
	einf->fini = MP_False;
	einf->strt = MP_False;
	einf->buflen=0;
	einf->pid=0;
	einf->prcsbuf=NULL;
	einf->win_id = XCreateWindow(display, root_window, einf->xpos,
				     einf->ypos, einf->width, einf->height,
				     BORDERWIDTH, CopyFromParent, InputOutput,
				     visual,
				     edit_mask, &edit_attr);
	if (state_open)
	    size_hints.flags = USPosition | USSize | PMinSize;
	else
	    size_hints.flags = PPosition | PSize | PMinSize;
	wm_hints.initial_state =
	    ((iconic || as_icon) ? IconicState : NormalState);
	size_hints.min_width =
	    size_hints.min_height = pos_y_with + SCROLLBARSIZE*3;
	XSetWMProperties(display, einf->win_id, NULL, NULL,
			 NULL, 0, &size_hints, &wm_hints, &class_hints);
	wm_hints.initial_state = NormalState;
	set_protocols(einf->win_id);

	i=0;
	einf->headername = NULL;
	einf->filename = NULL;
	einf->pathname = NULL;
	einf->outputname = NULL;
	if (set_name(einf, NULL) &&
	    add_window(einf->win_id, MAINEDITWINDOW,
		       root_window, (void *) einf, translate(helpname[EDITHELP]))) {
	    while (i<NR_BUTTON &&
		   button_make(i, einf->win_id, translate(editbutton[perm[i]]), &x, y, 1,
			       (void*) einf, helpname[edithelp[i]],
			       NULL, NULL, edit_handle_button,
			       edit_handle_button, edit_handle_button, NULL))
		i++,x+=BINTERSPACE;
	    w = sub_width(last_width);
	    h = sub_height(last_height);
	    if (i==NR_BUTTON) {
		einf->drawwin_id =
		    XCreateWindow(display, einf->win_id,
				  pos_x_with, pos_y_with, w-2, h-2, 1,
				  CopyFromParent, InputOutput,
				  visual,
				  edit_mask, &edit_attr);
		if (add_window(einf->drawwin_id, EDITWINDOW,
			       einf->win_id, NULL, translate(helpname[EDITSUBHELP])))
		    i++;
	    }
	    if (i==NR_BUTTON +1 &&
		(einf->scrollhor =
		 scrollbar_make(HORIZONTAL, einf->win_id, pos_x_with,
				pos_y_without, w, font_width(),
				edit_scrollto, (void*) einf)))
		i++;
	    if (i==NR_BUTTON+2 &&
		(einf->scrollver =
		 scrollbar_make(VERTICAL, einf->win_id, pos_x_without,
				pos_y_with, h, line_height(),
				edit_scrollto, (void*) einf)))
		i++;
	    
	}
	if (i<NR_BUTTON+3) {
	    free(einf->headername);
	    free(einf->pathname);
	    free(einf->filename);
	    XDestroyWindow(display, einf->win_id);
	    destroy_window(einf->win_id);
	} else {
	    is_opened = MP_True;
	    scrollbar_set(einf->scrollver, 0, 1);
	    scrollbar_set(einf->scrollhor, 0, 80);
	    move_selection = !as_icon;
	    einf->info = open_editwindow(&einf->drawwin_id, w-2, h-2);
	    move_selection = MP_False;
	    (void) window_changed(einf->info);
	    number_icon++;
	    number_open++;
	    edit_is_open = MP_True;
	    edit_iconized = (number_icon==number_open);
	    state_window = einf;
	    XMapSubwindows(display, einf->win_id);
	    XMapWindow(display, einf->win_id);
	}
    }
}
コード例 #15
0
ファイル: draw_map.c プロジェクト: Peanhua/diamond-girl
void draw_map(struct map * map, enum GAME_MODE game_mode, trait_t active_traits, int topleft_x, int topleft_y, int width, int height)
{
    gfx_gl_log("%s:%s: map", __FILE__, __FUNCTION__);
    if(globals.map_tilting == true)
        topleft_y += map->tilt;

    if(globals.opengl)
    {
#ifdef WITH_OPENGL
        glScissor(topleft_x, SCREEN_HEIGHT - topleft_y - height * 24 - 1, width * 24, height * 24);
        gfxgl_state(GL_SCISSOR_TEST, true);
#endif
    }
#ifdef WITH_NONOPENGL
    else
    {
        SDL_Rect r;

        r.x = topleft_x;
        r.y = topleft_y;
        r.w = width * 24;
        r.h = height * 24;
        SDL_SetClipRect(gfx_game_screen(), &r);
    }
#endif

    enum MOVE_DIRECTION amstate;

    if(game_mode == GAME_MODE_CLASSIC)
        amstate = MOVE_UP;
    else if(map->ameba_blocked == -1 || map->ameba_blocked == 0)
        amstate = MOVE_UP;
    else if(map->ameba_blocked_timer > map->frames_per_second * 3)
        amstate = MOVE_UP;
    else if(map->ameba_blocked_timer > map->frames_per_second * 1)
        amstate = MOVE_RIGHT;
    else
        amstate = MOVE_DOWN;

    if(globals.opengl)
    {
#ifdef WITH_OPENGL
        draw_map_opengl(map, game_mode, topleft_x, topleft_y, width, height, amstate);
#endif
    }
#ifdef WITH_NONOPENGL
    else
        draw_map_non_opengl(map, topleft_x, topleft_y, width, height, amstate);
#endif

#ifdef WITH_OPENGL
    bool texturechanged;

    texturechanged = false;
    if(globals.opengl && (game_mode == GAME_MODE_ADVENTURE || game_mode == GAME_MODE_PYJAMA_PARTY))
        if(map->girl->mob->alive && map->girl->mob->chat_bubble_timer > 0)
        {
            int x, y, w, h;

            w = font_width(map->girl->mob->chat_bubble);
            h = font_height();

            x = topleft_x + map->map_fine_x + (map->girl->mob->x - map->map_x    ) * 24 + 12 - w / 2;
            y = topleft_y + map->map_fine_y + (map->girl->mob->y - map->map_y - 1) * 24;

            x += map->move_offsets[2 * (map->girl->mob->x + map->girl->mob->y * map->width) + 0];
            y += map->move_offsets[2 * (map->girl->mob->x + map->girl->mob->y * map->width) + 1];

            SDL_Rect r;

            r.x = x - 4;
            r.y = y - 2;
            r.w = w + 4 * 2;
            r.h = h + 2 * 2;
            gfx_draw_rectangle(&r, 0x00, 0x00, 0x00, 0x80);

            font_write(x, y, map->girl->mob->chat_bubble);
            texturechanged = true;
        }
#endif

    if(map->level_start_anim_on > 0 && map->is_intermission == true)
    {
        struct image * img;

        img = gfx_image(GFX_IMAGE_INTERMISSION);
        if(img != NULL)
        {
            int x, y;

            x = 20 + get_rand(SCREEN_WIDTH - img->width - 40);
            y = 20 + get_rand(SCREEN_WIDTH - img->height - 40);
            gfx2d_draw_image(x, y, img);
        }
    }

    if(globals.opengl)
    {
#ifdef WITH_OPENGL
        gfxgl_state(GL_SCISSOR_TEST, false);
#endif
    }
#ifdef WITH_NONOPENGL
    else
        SDL_SetClipRect(gfx_game_screen(), NULL);
#endif


    gfx_gl_log("%s:%s: map cursor", __FILE__, __FUNCTION__);
    draw_map_cursor(map, topleft_x, topleft_y, width, height);
#ifdef WITH_OPENGL
    if(texturechanged == true)
        gfx_set_current_glyph_set(0);
#endif
    gfx_gl_log("%s:%s: map borders", __FILE__, __FUNCTION__);
    draw_map_borders(map, game_mode, active_traits, topleft_x, topleft_y, width, height);

    if(game_mode == GAME_MODE_ADVENTURE || game_mode == GAME_MODE_PYJAMA_PARTY || globals.smooth_classic_mode == true)
        if(map->girl->mob->moved_over_glyph != MAP_SIZEOF_)
        {
            int8_t * p;

            p = &map->move_offsets[2 * (map->girl->mob->x + map->girl->mob->y * map->width)];
            if(abs(p[0]) < 12 && abs(p[1]) < 12)
                map->girl->mob->moved_over_glyph = MAP_SIZEOF_;
        }
}