📄 look-cool.c
字号:
return 2; if (inbounds (bx, by, 2, h - 2 - w, w - 3, h - 3)) return 4; if (inbounds (bx, by, 2, h - 2 - w - 2 * w / 3, w - 3, h - 3 - w)) return 5; if (inbounds (bx, by, 2, w + 2 * w / 3 + 2 + (l - 5) * pos / 65535, w - 3, w + 2 * w / 3 + 7 + (l - 5) * (prop + pos) / 65535)) return 3; return 0;}int look_cool_scrollbar_handler (CWidget * w, XEvent * xevent, CEvent * cwevent){ static int buttonypos, y, whichscrbutton = 0; /* which of the five scroll bar buttons was pressed */ int xevent_xbutton_y, length, width; if (w->kind == C_VERTSCROLL_WIDGET) { xevent_xbutton_y = xevent->xbutton.y; length = w->height; width = w->width; } else { xevent_xbutton_y = xevent->xbutton.x; length = w->width; width = w->height; } switch (xevent->type) { case LeaveNotify: case Expose: w->options = 0; break; case ButtonRepeat: resolve_button (xevent, cwevent); if (cwevent->button == Button1 || cwevent->button == Button2) { int b; b = (*look->which_scrollbar_button) (cwevent->x, cwevent->y, w); if (b == 3 || !b) return 0; y = w->firstline; buttonypos = xevent_xbutton_y; w->options = whichscrbutton = b; cwevent->ident = w->ident; xevent->type = cwevent->type = ButtonPress; } break; case ButtonPress: resolve_button (xevent, cwevent); if (cwevent->button == Button1 || cwevent->button == Button2) { buttonypos = xevent_xbutton_y; y = w->firstline; w->options = whichscrbutton = (*look->which_scrollbar_button) (cwevent->x, cwevent->y, w); cwevent->ident = w->ident; w->search_start = w->firstline; w->search_len = w->numlines; } break; case ButtonRelease: resolve_button (xevent, cwevent); w->options = 32 + whichscrbutton; if (whichscrbutton == 3) { y += (double) (xevent_xbutton_y - buttonypos) * (double) 65535.0 / (length - 10 * width / 3 - 10); w->firstline = y; buttonypos = xevent_xbutton_y; } break; case MotionNotify: resolve_button (xevent, cwevent); if (cwevent->state & (Button1Mask | Button2Mask)) { w->options = whichscrbutton; if (whichscrbutton == 3) { y += (double) (xevent_xbutton_y - buttonypos) * (double) 65535.0 / (length - 10 * width / 3 - 10); w->firstline = y; buttonypos = xevent_xbutton_y; } } else w->options = 32 + (*look->which_scrollbar_button) (xevent->xmotion.x, xevent->xmotion.y, w); break; default: return 0; } if (w->firstline > 65535) w->firstline = 65535; if (cwevent->state & (Button1Mask | Button2Mask) || cwevent->type == ButtonPress || cwevent->type == ButtonRelease) if (w->scroll_bar_link && w->vert_scrollbar) (*w->scroll_bar_link) (w, w->vert_scrollbar, xevent, cwevent, whichscrbutton); if (xevent->type != Expose || !xevent->xexpose.count) (*look->render_scrollbar) (w); return 0;}static void look_cool_init_scrollbar_icons (CWidget * w){ return;}static int look_cool_get_scrollbar_size (int type){ if (type == C_HORISCROLL_WIDGET) return 13; return 20;}extern char *init_fg_color_red;extern char *init_fg_color_green;extern char *init_fg_color_blue;static void look_cool_get_button_color (XColor * color, int i){ double r, g, b, min_wc; r = 1 / atof (init_fg_color_red); g = 1 / atof (init_fg_color_green); b = 1 / atof (init_fg_color_blue); min_wc = min (r, min (g, b)); color->red = (float) 65535 *my_pow ((float) i / 20, r) * my_pow (0.75, -min_wc); color->green = (float) 65535 *my_pow ((float) i / 20, g) * my_pow (0.75, -min_wc); color->blue = (float) 65535 *my_pow ((float) i / 20, b) * my_pow (0.75, -min_wc); color->flags = DoRed | DoBlue | DoGreen;}static int look_cool_get_default_interwidget_spacing (void){ return 4;}int look_cool_window_handler (CWidget * w, XEvent * xevent, CEvent * cwevent){ static Window window_is_resizing = 0; static int windowx, windowy; static int wx = 0, wy = 0; static int wwidth = 0, wheight = 0; static int allowwindowmove = 0; static int allowwindowresize = 0; switch (xevent->type) { case ClientMessage: if (!w->disabled) cwevent->ident = w->ident; break; case Expose: if (!xevent->xexpose.count) render_window (w); break; case ButtonRelease: strcpy (cwevent->ident, w->ident); window_is_resizing = 0; resolve_button (xevent, cwevent); allowwindowmove = 0; allowwindowresize = 0; break; case ButtonPress: strcpy (cwevent->ident, w->ident); resolve_button (xevent, cwevent); if (cwevent->double_click == 1) { CWidget *c = CChildFocus (w); if (c) CFocus (c); } if (cwevent->button == Button1 && !(w->position & WINDOW_ALWAYS_LOWERED)) { XRaiseWindow (CDisplay, w->winid); CRaiseWindows (); } else if (cwevent->button == Button2 && !(w->position & WINDOW_ALWAYS_RAISED)) { XLowerWindow (CDisplay, w->winid); CLowerWindows (); } windowx = xevent->xbutton.x_root - w->x; windowy = xevent->xbutton.y_root - w->y; wx = xevent->xbutton.x; wy = xevent->xbutton.y; wwidth = w->width; wheight = w->height; if (wx + wy > w->width + w->height - 33 && w->position & WINDOW_RESIZABLE) allowwindowresize = 1; else allowwindowmove = 1; break; case MotionNotify: resolve_button (xevent, cwevent); if (!(w->position & WINDOW_UNMOVEABLE) && allowwindowmove && (cwevent->state & (Button1Mask | Button2Mask))) { w->x = xevent->xmotion.x_root - windowx; w->y = xevent->xmotion.y_root - windowy; if (w->x + xevent->xmotion.x < 2) w->x = -wx + 2; if (w->y + xevent->xmotion.y < 2) w->y = -wy + 2; XMoveWindow (CDisplay, w->winid, w->x, w->y); } if ((w->position & WINDOW_RESIZABLE) && allowwindowresize && (cwevent->state & (Button1Mask | Button2Mask))) { int wi, he; window_is_resizing = w->winid; wi = wwidth + xevent->xmotion.x_root - windowx - w->x; he = wheight + xevent->xmotion.y_root - windowy - w->y;/* this is actually for the edit windows, and needs to be generalized */ if (wi < w->mark1) wi = w->mark1; if (he < w->mark2) he = w->mark2; wi -= w->firstcolumn; wi -= wi % w->textlength; wi += w->firstcolumn; he -= w->firstline; he -= he % w->numlines; he += w->firstline; w->position &= ~WINDOW_MAXIMISED; CSetSize (w, wi, he); } break; } return 0;}extern Pixmap Cswitchon;extern Pixmap Cswitchoff;static void look_cool_render_switch (CWidget * wdt){ int w = wdt->width, h = wdt->height; Window win = wdt->winid; int x = 0, y = 0; CSetColor (COLOR_FLAT); CRectangle (win, x+5, y+5, w - 10, h - 10); CSetColor (wdt->fg); CSetBackgroundColor (wdt->bg); if (wdt->options & SWITCH_PICTURE_TYPE) { if (wdt->keypressed) XCopyPlane (CDisplay, Cswitchon, win, CGC, 0, 0, w, h, x, y, 1); else XCopyPlane (CDisplay, Cswitchoff, win, CGC, 0, 0, w, h, x, y, 1); } else { if (wdt->keypressed) { render_bevel (win, x + 3, y + 3, x + w - 4, y + h - 4, 2, 1); }else render_bevel (win, x + 3, y + 3, x + w - 4, y + h - 4, 2, 0); } if (wdt->options & (BUTTON_HIGHLIGHT | BUTTON_PRESSED)) render_rounded_bevel (win, x, y, x + w - 1, y + h - 1, 7, 1, 1); else render_rounded_bevel (win, x, y, x + w - 1, y + h - 1, 7, 1, 0);}extern unsigned long edit_normal_background_color;static void look_cool_edit_render_tidbits (CWidget * wdt){ int isfocussed; int w = wdt->width, h = wdt->height; Window win; win = wdt->winid; isfocussed = (win == CGetFocus ()); CSetColor (COLOR_FLAT); if (isfocussed) { render_bevel (win, 0, 0, w - 1, h - 1, 3, 1); /*most outer border bevel */ } else { render_bevel (win, 2, 2, w - 3, h - 3, 1, 1); /*border bevel */ render_bevel (win, 0, 0, w - 1, h - 1, 2, 0); /*most outer border bevel */ } CSetColor (edit_normal_background_color); CLine (CWindowOf (wdt), 3, 3, 3, CHeightOf (wdt) - 4);}CWidget *look_cool_draw_exclam_cancel_button (char *ident, Window win, int x, int y){ CWidget *wdt; wdt = CDrawPixmapButton (ident, win, x, y, PIXMAP_BUTTON_EXCLAMATION); return wdt;}CWidget *look_cool_draw_tick_cancel_button (char *ident, Window win, int x, int y){ CWidget *wdt; wdt = CDrawPixmapButton (ident, win, x, y, PIXMAP_BUTTON_TICK); return wdt;}CWidget *look_cool_draw_cross_cancel_button (char *ident, Window win, int x, int y){ CWidget *wdt; wdt = CDrawPixmapButton (ident, win, x, y, PIXMAP_BUTTON_CROSS); return wdt;}static void look_cool_render_fielded_textbox_tidbits (CWidget * w, int isfocussed){ if (isfocussed) { render_bevel (w->winid, 0, 0, w->width - 1, w->height - 1, 3, 1); /*most outer border bevel */ } else { render_bevel (w->winid, 2, 2, w->width - 3, w->height - 3, 1, 1); /*border bevel */ render_bevel (w->winid, 0, 0, w->width - 1, w->height - 1, 2, 0); /*most outer border bevel */ } CSetColor (edit_normal_background_color); CLine (w->winid, 3, 3, 3, w->height - 4);}static void look_cool_render_textbox_tidbits (CWidget * w, int isfocussed){ if (isfocussed) { render_bevel (w->winid, 0, 0, w->width - 1, w->height - 1, 3, 1); /*most outer border bevel */ } else { render_bevel (w->winid, 2, 2, w->width - 3, w->height - 3, 1, 1); /*border bevel */ render_bevel (w->winid, 0, 0, w->width - 1, w->height - 1, 2, 0); /*most outer border bevel */ }}static void look_cool_render_passwordinput_tidbits (CWidget * wdt, int isfocussed){ int w = wdt->width, h = wdt->height; Window win = wdt->winid; if (isfocussed) { render_bevel (win, 0, 0, w - 1, h - 1, 3, 1); } else { render_bevel (win, 2, 2, w - 3, h - 3, 1, 1); render_bevel (win, 0, 0, w - 1, h - 1, 2, 0); }}static void look_cool_render_textinput_tidbits (CWidget * wdt, int isfocussed){ int w = wdt->width, h = wdt->height; Window win = wdt->winid; if (isfocussed) { render_bevel (win, 0, 0, w - h - 1, h - 1, 3, 1); /*most outer border bevel */ } else { render_bevel (win, 2, 2, w - h - 3, h - 3, 1, 1); /*border bevel */ render_bevel (win, 0, 0, w - h - 1, h - 1, 2, 0); /*most outer border bevel */ } if (wdt->options & BUTTON_PRESSED) { CRectangle (win, w - h + 2, 2, h - 4, h - 4); render_bevel (win, w - h, 0, w - 1, h - 1, 2, 3); } else if (wdt->options & BUTTON_HIGHLIGHT) { CRectangle (win, w - h + 1, 1, h - 2, h - 2); render_bevel (win, w - h, 0, w - 1, h - 1, 1, 2); } else { CRectangle (win, w - h + 2, 2, h - 4, h - 4); render_bevel (win, w - h, 0, w - 1, h - 1, 2, 2); }}extern struct focus_win focus_border;static void render_focus_border_n (Window win, int i){ int j; j = (i > 3) + 1; if (win == focus_border.top) { render_bevel (win, 0, 0, focus_border.width + 2 * WIDGET_FOCUS_RING - 1, focus_border.height + 2 * WIDGET_FOCUS_RING - 1, j, 0); render_bevel (win, i, i, focus_border.width + 2 * WIDGET_FOCUS_RING - 1 - i, focus_border.height + 2 * WIDGET_FOCUS_RING - 1 - i, 2, 1); } else if (win == focus_border.bottom) { render_bevel (win, 0, 0 - focus_border.height, focus_border.width + 2 * WIDGET_FOCUS_RING - 1, WIDGET_FOCUS_RING - 1, j, 0); render_bevel (win, i, i - focus_border.height, focus_border.width + 2 * WIDGET_FOCUS_RING - 1 - i, WIDGET_FOCUS_RING - 1 - i, 2, 1); } else if (win == focus_border.left) { render_bevel (win, 0, 0 - WIDGET_FOCUS_RING, focus_border.width + 2 * WIDGET_FOCUS_RING - 1, focus_border.height + WIDGET_FOCUS_RING - 1, j, 0); render_bevel (win, i, i - WIDGET_FOCUS_RING, focus_border.width + 2 * WIDGET_FOCUS_RING - 1 - i, focus_border.height + WIDGET_FOCUS_RING - 1 - i, 2, 1); } else if (win == focus_border.right) { render_bevel (win, 0 + WIDGET_FOCUS_RING - focus_border.width, 0 - WIDGET_FOCUS_RING, WIDGET_FOCUS_RING - 1, focus_border.height + WIDGET_FOCUS_RING - 1, j, 0); render_bevel (win, i + WIDGET_FOCUS_RING - focus_border.width, i - WIDGET_FOCUS_RING, WIDGET_FOCUS_RING - 1 - i, focus_border.height + WIDGET_FOCUS_RING - 1 - i, 2, 1); }}static void look_cool_render_focus_border (Window win){ render_focus_border_n (win, focus_border.border);}static int look_cool_get_extra_window_spacing (void){ return 2;}static int look_cool_get_focus_ring_size (void){ return 4;}static unsigned long look_cool_get_button_flat_color (void){ return color_widget(9);}static int look_cool_get_window_resize_bar_thickness (void){ return 0;}static int look_cool_get_switch_size (void){ return FONT_PIX_PER_LINE + TEXT_RELIEF * 2 + 2 + 4;}static int look_cool_get_fielded_textbox_hscrollbar_width (void){ return 12;}struct look look_cool = { look_cool_get_default_interwidget_spacing, look_cool_menu_draw, look_cool_get_menu_item_extents, look_cool_render_menu_button, look_cool_render_button, look_cool_render_bar, look_cool_render_raised_bevel, look_cool_render_sunken_bevel, look_cool_draw_hotkey_understroke, look_cool_get_default_widget_font, look_cool_render_text, look_cool_render_window, look_cool_render_scrollbar, look_cool_get_scrollbar_size, look_cool_init_scrollbar_icons, look_cool_which_scrollbar_button, look_cool_scrollbar_handler, look_cool_get_button_color, look_cool_get_extra_window_spacing, look_cool_window_handler, look_cool_get_focus_ring_size, look_cool_get_button_flat_color, look_cool_get_window_resize_bar_thickness, look_cool_render_switch, look_cool_get_switch_size, look_cool_draw_browser, look_cool_get_file_or_dir, look_cool_draw_file_list, look_cool_redraw_file_list, look_cool_get_file_list_line, look_cool_search_replace_dialog, look_cool_edit_render_tidbits, look_cool_draw_exclam_cancel_button, look_cool_draw_tick_cancel_button, look_cool_draw_cross_cancel_button, look_cool_draw_tick_cancel_button, look_cool_render_fielded_textbox_tidbits, look_cool_render_textbox_tidbits, look_cool_get_fielded_textbox_hscrollbar_width, look_cool_render_textinput_tidbits, look_cool_render_passwordinput_tidbits, look_cool_render_focus_border,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -