⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 look-cool.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 4 页
字号:
    CAddCallback (catstrs (ident, ".ok", 0), cb_browser);    CAddCallback (catstrs (ident, ".cancel", 0), cb_browser);    CFocus (CIdent (catstrs (ident, ".finp", 0)));}/* }}} file browser stuff */int find_menu_hotkey (struct menu_item m[], int this, int num);/* outermost bevel */#define BEVEL_MAIN	2/* next-outermost bevel */#define BEVEL_IN 	4#define BEVEL_OUT	5/* between items, and between items and next-outermost bevel */#define SPACING		4/* between items rectangle and text */#define RELIEF		(TEXT_RELIEF + 1)#define S		SPACING/* between window border and items */#define O		(BEVEL_OUT + SPACING)/* total height of an item *//* size of bar item */#define BAR_HEIGHT	8#define ITEM_BEVEL_TYPE 1#define ITEM_BEVEL      1#define H		(FONT_PIX_PER_LINE + RELIEF * 2)#define B		BAR_HEIGHTstatic char *look_cool_get_default_widget_font (void){    return "-*-helvetica-bold-r-*--%d-*-*-*-*-*-*";}static void look_cool_get_menu_item_extents (int n, int j, struct menu_item m[], int *border, int *relief, int *y1, int *y2){    int i, n_items = 0, n_bars = 0;    *border = O;    *relief = RELIEF;    if (!n || j < 0) {	*y1 = O;	*y2 = *y1 + H;    } else {	int not_bar;	not_bar = (m[j].text[2] != '\0');	for (i = 0; i < j; i++)	    if (m[i].text[2])		n_items++;	    else		n_bars++;	*y1 = O + n_items * (H + S) + n_bars * (B + S) + (not_bar ? 0 : 2);	*y2 = *y1 + (not_bar ? H : (B - 4));    }}static void look_cool_menu_draw (Window win, int w, int h, struct menu_item m[], int n, int light){    int i, y1, y2, offset = 0;    static int last_light = 0, last_n = 0;    static Window last_win = 0;    render_bevel (win, 0, 0, w - 1, h - 1, BEVEL_MAIN, 0);    render_bevel (win, BEVEL_IN, BEVEL_IN, w - 1 - BEVEL_IN, h - 1 - BEVEL_IN, BEVEL_OUT - BEVEL_IN, 1);    if (last_win == win && last_n != n) {	XClearWindow (CDisplay, win);    } else if (last_light >= 0 && last_light < n) {	int border, relief;	look_cool_get_menu_item_extents (n, last_light, m, &border, &relief, &y1, &y2);	CSetColor (COLOR_FLAT);	CRectangle (win, O - 1, y1 - 1, w - O * 2 + 2, y2 - y1 + 2);    }    last_win = win;    last_n = n;    CPushFont ("widget", 0);    for (i = 0; i < n; i++) {	int border, relief;	look_cool_get_menu_item_extents (n, i, m, &border, &relief, &y1, &y2);	if (i == light && m[i].text[2]) {	    offset = 1;	    CSetColor (color_widget (11));	    CRectangle (win, O + 1, y1 + 1, w - O * 2 - 2, y2 - y1 - 2);	    render_bevel (win, O - 1, y1 - 1, w - O, y2, 2, 0);	} else {	    if (!(m[i].text[2]))		render_bevel (win, O + 6, y1, w - O - 1 - 6, y2 - 1, 2, 0);	    else		render_bevel (win, O, y1, w - O - 1, y2 - 1, ITEM_BEVEL, ITEM_BEVEL_TYPE);	    offset = 0;	}	if (m[i].text[2]) {	    char *u;	    u = strrchr (m[i].text, '\t');	    if (u)		*u = 0;	    CSetColor (COLOR_BLACK);	    if (m[i].hot_key == '~')		m[i].hot_key = find_menu_hotkey (m, i, n);	    if (i == light)		CSetBackgroundColor (color_widget (11));	    else		CSetBackgroundColor (COLOR_FLAT);	    drawstring_xy_hotkey (win, RELIEF + O - offset,			  RELIEF + y1 - offset, m[i].text, m[i].hot_key);	    if (u) {		drawstring_xy (win, RELIEF + O + (w - (O + RELIEF) * 2 - CImageStringWidth (u + 1)) - offset,			       RELIEF + y1 - offset, u + 1);		*u = '\t';	    }	}    }    last_light = light;    CPopFont ();}static void look_cool_render_menu_button (CWidget * wdt){    int w = wdt->width, h = wdt->height;    int x = 0, y = 0;    Window win = wdt->winid;    if (wdt->disabled)	goto disabled;    if (wdt->options & BUTTON_PRESSED) {	render_bevel (win, x, y, x + w - 1, y + h - 1, 2, 1);    } else if (wdt->options & BUTTON_HIGHLIGHT) {	CSetColor (COLOR_FLAT);	XDrawRectangle (CDisplay, win, CGC, x + 1, y + 1, w - 3, h - 3);	render_bevel (win, x, y, x + w - 1, y + h - 1, 1, 0);    } else {  disabled:	CSetColor (COLOR_FLAT);	XDrawRectangle (CDisplay, win, CGC, x, y, w - 1, h - 1);	XDrawRectangle (CDisplay, win, CGC, x + 1, y + 1, w - 3, h - 3);    }    if (!wdt->label)	return;    if (!(*(wdt->label)))	return;    CSetColor (COLOR_BLACK);    CPushFont ("widget", 0);    CSetBackgroundColor (COLOR_FLAT);    drawstring_xy_hotkey (win, x + 2 + BUTTON_RELIEF, y + 2 + BUTTON_RELIEF, wdt->label, wdt->hotkey);    CPopFont ();}static void look_cool_render_button (CWidget * wdt){    int w = wdt->width, h = wdt->height;    int x = 0, y = 0;    Window win = wdt->winid;#define BUTTON_BEVEL 2    if (wdt->disabled)	goto disabled;    if (wdt->options & BUTTON_PRESSED) {	render_bevel (win, x, y, x + w - 1, y + h - 1, BUTTON_BEVEL, 1);    } else if (wdt->options & BUTTON_HIGHLIGHT) {	CSetColor (COLOR_FLAT);	XDrawRectangle (CDisplay, win, CGC, x + 1, y + 1, w - 3, h - 3);	render_bevel (win, x, y, x + w - 1, y + h - 1, 1, 0);    } else {      disabled:	render_bevel (win, x, y, x + w - 1, y + h - 1, BUTTON_BEVEL, 0);    }    if (!wdt->label)	return;    if (!(*(wdt->label)))	return;    CSetColor (COLOR_BLACK);    CSetBackgroundColor (COLOR_FLAT);    CPushFont ("widget", 0);    drawstring_xy_hotkey (win, x + 2 + BUTTON_RELIEF, y + 2 + BUTTON_RELIEF, wdt->label, wdt->hotkey);    CPopFont ();}static void look_cool_render_bar (CWidget * wdt){    int w = wdt->width, h = wdt->height;    Window win = wdt->winid;    CSetColor (COLOR_FLAT);    CLine (win, 1, 1, w - 2, 1);    render_bevel (win, 0, 0, w - 1, h - 1, 1, 1);}void look_cool_render_sunken_bevel (Window win, int x1, int y1, int x2, int y2, int thick, int sunken){    int i;    if ((sunken & 2)) {	CSetColor (COLOR_FLAT);	CRectangle (win, x1 + thick, y1 + thick, x2 - x1 - 2 * thick + 1, y2 - y1 - 2 * thick + 1);    }    i = /* thick - 1 */ 0;    CSetColor (color_widget (11));    CLine (win, x1 + i, y2 - i, x2 - 1 - i, y2 - i);    CLine (win, x2 - i, y1 + i, x2 - i, y2 - i - 1);    CSetColor (color_widget (7));    CLine (win, x1, y1, x1, y2 - 1);    CLine (win, x1, y1, x2 - 1, y1);    if (thick > 1) {	CSetColor (color_widget (4));	for (i = 1; i < thick; i++) {	    CLine (win, x1 + i + 1, y1 + i, x2 - 1 - i, y1 + i);	    CLine (win, x1 + i, y1 + i, x1 + i, y2 - 1 - i);	}	CSetColor (color_widget (13));	for (i = 1; i < thick; i++) {	    CLine (win, x2 - i, y1 + i, x2 - i, y2 - i - 1);	    CLine (win, x1 + i, y2 - i, x2 - i - 1, y2 - i);	}    }    CSetColor (color_widget (14));    for (i = 0; i < thick; i++)	XDrawPoint (CDisplay, win, CGC, x2 - i, y2 - i);}static void look_cool_render_raised_bevel (Window win, int x1, int y1, int x2, int y2, int thick, int sunken){    int i;    if ((sunken & 2)) {	CSetColor (COLOR_FLAT);	CRectangle (win, x1 + thick, y1 + thick, x2 - x1 - 2 * thick + 1, y2 - y1 - 2 * thick + 1);    }    i = thick - 1;    CSetColor (color_widget (7));    CLine (win, x1 + i, y2 - i, x2 - i - 1, y2 - i);    CLine (win, x2 - i, y1 + i, x2 - i, y2 - i);    CSetColor (color_widget (12));    CLine (win, x1 + i, y1 + i, x1 + i, y2 - 1 - i);    CLine (win, x1 + 1 + i, y1 + i, x2 - 1 - i, y1 + i);    if (thick > 1) {	CSetColor (color_widget (11));	for (i = 0; i < thick - 1; i++) {	    CLine (win, x1 + i + 1, y1 + i, x2 - 1 - i, y1 + i);	    CLine (win, x1 + i, y1 + i + 1, x1 + i, y2 - 1 - i);	}	CSetColor (color_widget (4));	for (i = 0; i < thick - 1; i++) {	    CLine (win, x2 - i, y1 + i, x2 - i, y2 - i);	    CLine (win, x1 + i, y2 - i, x2 - i - 1, y2 - i);	}    }    CSetColor (color_widget (15));    for (i = 0; i < thick; i++)	XDrawPoint (CDisplay, win, CGC, x1 + i, y1 + i);}static void look_cool_draw_hotkey_understroke (Window win, int x, int y, int hotkey){    CLine (win, x, y, x + FONT_PER_CHAR (hotkey), y);    CLine (win, x - 1, y + 1, x + FONT_PER_CHAR (hotkey) / 2, y + 1);    CLine (win, x - 1, y + 2, x + FONT_PER_CHAR (hotkey) / 4 - 1, y + 2);}static void look_cool_render_text (CWidget * wdt){    Window win = wdt->winid;    char text[1024], *p, *q;    int hot, y, w = wdt->width, center = 0;    CPushFont ("widget", 0);    CSetColor (COLOR_FLAT);    CRectangle (win, 1, 1, w - 2, wdt->height - 2);    CSetColor (COLOR_BLACK);    hot = wdt->hotkey;		/* a letter that needs underlining */    y = 1;			/* bevel */    q = wdt->text;    CSetBackgroundColor (COLOR_FLAT);    for (;;) {	p = strchr (q, '\n');	if (!p) {	/* last line */	    if (wdt->options & TEXT_CENTRED)		center = (wdt->width - (TEXT_RELIEF + 1) * 2 - CImageTextWidth (q, strlen (q))) / 2;	    drawstring_xy_hotkey (win, TEXT_RELIEF + 1 + center,		 TEXT_RELIEF + y, q, hot);	    break;	} else {	    int l;	    l = min (1023, (unsigned long) p - (unsigned long) q);	    memcpy (text, q, l);	    text[l] = 0;	    if (wdt->options & TEXT_CENTRED)		center = (wdt->width - (TEXT_RELIEF + 1) * 2 - CImageTextWidth (q, l)) / 2;	    drawstring_xy_hotkey (win, TEXT_RELIEF + 1 + center,		 TEXT_RELIEF + y, text, hot);	}	y += FONT_PIX_PER_LINE;	hot = 0;	/* only for first line */	q = p + 1;	/* next line */    }    render_bevel (win, 0, 0, w - 1, wdt->height - 1, 1, 1);    CPopFont ();}static void look_cool_render_window (CWidget * wdt){    int w = wdt->width, h = wdt->height;    Window win = wdt->winid;    if (wdt->options & WINDOW_NO_BORDER)	return;    if (wdt->position & WINDOW_RESIZABLE) {	CSetColor (color_widget (13));	CLine (win, w - 4, h - 31, w - 31, h - 4);	CLine (win, w - 4, h - 21, w - 21, h - 4);	CLine (win, w - 4, h - 11, w - 11, h - 4);	CLine (win, w - 4, h - 32, w - 32, h - 4);	CLine (win, w - 4, h - 22, w - 22, h - 4);	CLine (win, w - 4, h - 12, w - 12, h - 4);	CSetColor (color_widget (3));	CLine (win, w - 4, h - 27, w - 27, h - 4);	CLine (win, w - 4, h - 17, w - 17, h - 4);	CLine (win, w - 4, h -  7, w -  7, h - 4);	CLine (win, w - 4, h - 28, w - 28, h - 4);	CLine (win, w - 4, h - 18, w - 18, h - 4);	CLine (win, w - 4, h -  8, w -  8, h - 4);    }    render_bevel (win, 0, 0, w - 1, h - 1, 2, 0);    if (CRoot != wdt->parentid)	if (win == CGetFocus ())	    render_bevel (win, 4, 4, w - 5, h - 5, 3, 1);}static void look_cool_render_vert_scrollbar (Window win, int x, int y, int w, int h, int pos, int prop, int pos2, int prop2, int flags){    int l = h - 10 * w / 3 - 5;    render_bevel (win, 0, 0, w - 1, h - 1, 2, 1);    CSetColor (COLOR_FLAT);    CRectangle (win, 2, w + 2 * w / 3 + 2, w - 4, (l - 5) * pos / 65535);    CRectangle (win, 2, w + 2 * w / 3 + 3 + l * (prop + pos) / 65535, w - 4, h - 1 - w - 2 * w / 3 - (w + 2 * w / 3 + 4 + l * (prop + pos) / 65535));    if (flags & 32) {	render_bevel (win, 2, 2, w - 3, w + 1, 2 - ((flags & 15) == 1), 2);	render_bevel (win, 2, w + 2, w - 3, w + 2 * w / 3 + 1, 2 - ((flags & 15) == 2), 2);	render_bevel (win, 2, h - 2 - w, w - 3, h - 3, 2 - ((flags & 15) == 4), 2);	render_bevel (win, 2, h - 2 - w - 2 * w / 3, w - 3, h - 3 - w, 2 - ((flags & 15) == 5), 2);	render_bevel (win, 2, w + 2 * w / 3 + 2 + (l - 5) * pos / 65535, w - 3, w + 2 * w / 3 + 7 + (l - 5) * (prop + pos) / 65535, 2 - ((flags & 15) == 3), 2);    } else {	render_bevel (win, 2, 2, w - 3, w + 1, 2, 2 | ((flags & 15) == 1));	render_bevel (win, 2, w + 2, w - 3, w + 2 * w / 3 + 1, 2, 2 | ((flags & 15) == 2));	render_bevel (win, 2, h - 2 - w, w - 3, h - 3, 2, 2 | ((flags & 15) == 4));	render_bevel (win, 2, h - 2 - w - 2 * w / 3, w - 3, h - 3 - w, 2, 2 | ((flags & 15) == 5));	if ((flags & 15) == 3) {	    CSetColor (color_widget (5));	    XDrawRectangle (CDisplay, win, CGC, 4, w + 2 * w / 3 + 4 + (l - 5) * pos2 / 65535, w - 10, 2 + (l - 5) * prop2 / 65535);	}	render_bevel (win, 2, w + 2 * w / 3 + 2 + (l - 5) * pos / 65535, w - 3, w + 2 * w / 3 + 7 + (l - 5) * (prop + pos) / 65535, 2, 2 | ((flags & 15) == 3));    }}static void look_cool_render_hori_scrollbar (Window win, int x, int y, int h, int w, int pos, int prop, int flags){    int l = h - 10 * w / 3 - 5, k;    k = (l - 5) * pos / 65535;    render_bevel (win, 0, 0, h - 1, w - 1, 2, 1);    CSetColor (COLOR_FLAT);    CRectangle (win, w + 2 * w / 3 + 2, 2, (l - 5) * pos / 65535, w - 4);    CRectangle (win, w + 2 * w / 3 + 3 + l * (prop + pos) / 65535, 2, h - 1 - w - 2 * w / 3 - (w + 2 * w / 3 + 4 + l * (prop + pos) / 65535), w - 4);    if (flags & 32) {	render_bevel (win, 2, 2, w + 1, w - 3, 2 - ((flags & 15) == 1), 2);	render_bevel (win, w + 2, 2, w + 2 * w / 3 + 1, w - 3, 2 - ((flags & 15) == 2), 2);	render_bevel (win, h - 2 - w, 2, h - 3, w - 3, 2 - ((flags & 15) == 4), 2);	render_bevel (win, h - 2 - w - 2 * w / 3, 2, h - 3 - w, w - 3, 2 - ((flags & 15) == 5), 2);	render_bevel (win, w + 2 * w / 3 + 2 + k, 2, w + 2 * w / 3 + 7 + (l - 5) * (prop + pos) / 65535, w - 3, 2 - ((flags & 15) == 3), 2);    } else {	render_bevel (win, 2, 2, w + 1, w - 3, 2, 2 | ((flags & 15) == 1));	render_bevel (win, w + 2, 2, w + 2 * w / 3 + 1, w - 3, 2, 2 | ((flags & 15) == 2));	render_bevel (win, h - 2 - w, 2, h - 3, w - 3, 2, 2 | ((flags & 15) == 4));	render_bevel (win, h - 2 - w - 2 * w / 3, 2, h - 3 - w, w - 3, 2, 2 | ((flags & 15) == 5));	render_bevel (win, w + 2 * w / 3 + 2 + k, 2, w + 2 * w / 3 + 7 + (l - 5) * (prop + pos) / 65535, w - 3, 2, 2 | ((flags & 15) == 3));    }}static void look_cool_render_scrollbar (CWidget * wdt){    int flags = wdt->options;    if (!wdt)	return;    if (wdt->numlines < 0)	wdt->numlines = 0;    if (wdt->firstline < 0)	wdt->firstline = 0;    if (wdt->firstline > 65535)	wdt->firstline = 65535;    if (wdt->firstline + wdt->numlines >= 65535)	wdt->numlines = 65535 - wdt->firstline;    if (wdt->kind == C_VERTSCROLL_WIDGET) {	look_cool_render_vert_scrollbar (wdt->winid,			      wdt->x, wdt->y,			      wdt->width, wdt->height,			      wdt->firstline, wdt->numlines, wdt->search_start, wdt->search_len, flags);    } else	look_cool_render_hori_scrollbar (wdt->winid,			      wdt->x, wdt->y,			      wdt->width, wdt->height,			      wdt->firstline, wdt->numlines, flags);    if (wdt->scroll_bar_extra_render)	(*wdt->scroll_bar_extra_render) (wdt);}/*   Which scrollbar button was pressed: 3 is the middle button ? */static int look_cool_which_scrollbar_button (int bx, int by, CWidget * wdt){    int w, h;    int pos = wdt->firstline;    int prop = wdt->numlines;    int l;    if (wdt->kind == C_VERTSCROLL_WIDGET) {	w = wdt->width;	h = wdt->height;    } else {	int t = bx;	bx = by;	by = t;	w = wdt->height;	h = wdt->width;    }    l = h - 10 * w / 3 - 5;    if (inbounds (bx, by, 2, 2, w - 3, w + 1))	return 1;    if (inbounds (bx, by, 2, w + 2, w - 3, w + 2 * w / 3 + 1))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -