📄 look-gtk.c
字号:
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_gtk_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) { bevel_background_color = ((flags & 15) == 1) ? color_widget (14) : COLOR_FLAT; render_bevel (win, 2, 2, w - 3, w + 1, 2, 2); bevel_background_color = ((flags & 15) == 2) ? color_widget (14) : COLOR_FLAT; render_bevel (win, 2, w + 2, w - 3, w + 2 * w / 3 + 1, 2, 2); bevel_background_color = ((flags & 15) == 4) ? color_widget (14) : COLOR_FLAT; render_bevel (win, 2, h - 2 - w, w - 3, h - 3, 2, 2); bevel_background_color = ((flags & 15) == 5) ? color_widget (14) : COLOR_FLAT; render_bevel (win, 2, h - 2 - w - 2 * w / 3, w - 3, h - 3 - w, 2, 2); bevel_background_color = ((flags & 15) == 3) ? color_widget (14) : COLOR_FLAT; 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); bevel_background_color = COLOR_FLAT; } 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_gtk_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) { bevel_background_color = ((flags & 15) == 1) ? color_widget (14) : COLOR_FLAT; render_bevel (win, 2, 2, w + 1, w - 3, 2, 2); bevel_background_color = ((flags & 15) == 2) ? color_widget (14) : COLOR_FLAT; render_bevel (win, w + 2, 2, w + 2 * w / 3 + 1, w - 3, 2, 2); bevel_background_color = ((flags & 15) == 4) ? color_widget (14) : COLOR_FLAT; render_bevel (win, h - 2 - w, 2, h - 3, w - 3, 2, 2); bevel_background_color = ((flags & 15) == 5) ? color_widget (14) : COLOR_FLAT; render_bevel (win, h - 2 - w - 2 * w / 3, 2, h - 3 - w, w - 3, 2, 2); bevel_background_color = ((flags & 15) == 3) ? color_widget (14) : COLOR_FLAT; render_bevel (win, w + 2 * w / 3 + 2 + k, 2, w + 2 * w / 3 + 7 + (l - 5) * (prop + pos) / 65535, w - 3, 2, 2); bevel_background_color = COLOR_FLAT; } 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_gtk_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_gtk_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_gtk_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_gtk_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)) 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;}extern int look_cool_scrollbar_handler (CWidget * w, XEvent * xevent, CEvent * cwevent);static void look_gtk_init_scrollbar_icons (CWidget * w){ return;}static int look_gtk_get_scrollbar_size (int type){ if (type == C_HORISCROLL_WIDGET) return 13; return 20;}static void look_gtk_get_button_color (XColor * color, int i){ color->red = i * 65535 / 15; color->green = i * 65535 / 15; color->blue = i * 65535 / 15; color->flags = DoRed | DoBlue | DoGreen;#if 0 double r, g, b, min_wc; r = 0.6; g = 0.6; b = 0.6; 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;#endif}static int look_gtk_get_default_interwidget_spacing (void){ return 2;}extern int look_cool_window_handler (CWidget * w, XEvent * xevent, CEvent * cwevent);extern Pixmap Cswitchon;extern Pixmap Cswitchoff;static void look_gtk_render_switch (CWidget * wdt){ int w = wdt->width, h = wdt->height; Window win = wdt->winid; if (wdt->options & BUTTON_HIGHLIGHT) bevel_background_color = color_widget (14); CSetColor (bevel_background_color); CRectangle (win, 0, 0, w, h); render_bevel (win, w / 2 - 5, h / 2 - 5, w / 2 + 4, h / 2 + 4, 2, wdt->keypressed ? 1 : 0); bevel_background_color = COLOR_FLAT;}extern unsigned long edit_normal_background_color;static void look_gtk_edit_render_tidbits (CWidget * wdt){ int isfocussed; int w = wdt->width, h = wdt->height; Window win; win = wdt->winid; isfocussed = (win == CGetFocus ()); bevel_background_color = edit_normal_background_color; if (isfocussed) { render_bevel (win, 1, 1, w - 2, h - 2, 2, 1); /*most outer border bevel */ CSetColor (color_widget (0)); XDrawRectangle(CDisplay, win, CGC, 0, 0, w - 1, h - 1); } else { render_bevel (win, 0, 0, w - 1, h - 1, 3, 1); /*most outer border bevel */ } bevel_background_color = COLOR_FLAT; CSetColor (edit_normal_background_color); CLine (CWindowOf (wdt), 3, 3, 3, CHeightOf (wdt) - 4);}extern CWidget *look_cool_draw_exclam_cancel_button (char *ident, Window win, int x, int y);extern CWidget *look_cool_draw_tick_cancel_button (char *ident, Window win, int x, int y);extern CWidget *look_cool_draw_cross_cancel_button (char *ident, Window win, int x, int y);extern unsigned long option_text_bg_normal;static void look_gtk_render_fielded_textbox_tidbits (CWidget * w, int isfocussed){ bevel_background_color = COLOR_WHITE; if (isfocussed) { render_bevel (w->winid, 1, 1, w->width - 2, w->height - 2, 2, 1); /*most outer border bevel */ CSetColor (color_widget (0)); XDrawRectangle (CDisplay, w->winid, CGC, 0, 0, w->width - 1, w->height - 1); } else { render_bevel (w->winid, 0, 0, w->width - 1, w->height - 1, 3, 1); /*most outer border bevel */ } bevel_background_color = COLOR_FLAT; CSetColor (color_palette (option_text_bg_normal)); CLine (w->winid, 3, 3, 3, w->height - 4);}static void look_gtk_render_textbox_tidbits (CWidget * w, int isfocussed){ bevel_background_color = COLOR_WHITE; if (isfocussed) { render_bevel (w->winid, 1, 1, w->width - 2, w->height - 2, 2, 1); /*most outer border bevel */ CSetColor (color_widget (0)); XDrawRectangle (CDisplay, w->winid, CGC, 0, 0, w->width - 1, w->height - 1); } else { render_bevel (w->winid, 0, 0, w->width - 1, w->height - 1, 3, 1); /*most outer border bevel */ } bevel_background_color = COLOR_FLAT;}static void look_gtk_render_passwordinput_tidbits (CWidget * wdt, int isfocussed){ int w = wdt->width, h = wdt->height; Window win = wdt->winid; bevel_background_color = COLOR_WHITE; if ((win == CGetFocus ())) { render_bevel (win, 1, 1, w - 2, h - 2, 2, 1); /*most outer border bevel */ CSetColor (color_widget (0)); XDrawRectangle (CDisplay, win, CGC, 0, 0, w - 1, h - 1); } else { render_bevel (win, 0, 0, w - 1, h - 1, 3, 1); /*most outer border bevel */ } bevel_background_color = COLOR_FLAT;}static void look_gtk_render_textinput_tidbits (CWidget * wdt, int isfocussed){ int w = wdt->width, h = wdt->height; Window win = wdt->winid; bevel_background_color = COLOR_WHITE; if (isfocussed) { render_bevel (win, 1, 1, w - h - 2, h - 2, 2, 1); /*most outer border bevel */ CSetColor (color_widget (0)); XDrawRectangle (CDisplay, win, CGC, 0, 0, w - h - 1, h - 1); } else { render_bevel (win, 0, 0, w - h - 1, h - 1, 3, 1); /*most outer border bevel */ } bevel_background_color = COLOR_FLAT; /* history button to the right */ if (wdt->options & BUTTON_PRESSED) { CSetColor (COLOR_FLAT); CRectangle (win, w - h + 2, 2, h - 4, h - 4); render_bevel (win, w - h, 0, w - 1, h - 1, 2, 1); } else if (wdt->options & BUTTON_HIGHLIGHT) { bevel_background_color = color_widget (14); render_bevel (win, w - h, 0, w - 1, h - 1, 2, 2); bevel_background_color = COLOR_FLAT; } else { CSetColor (COLOR_FLAT); CRectangle (win, w - h + 2, 2, h - 4, h - 4); render_bevel (win, w - h, 0, w - 1, h - 1, 2, 0); }}extern struct focus_win focus_border;static void look_gtk_render_focus_border (Window win){ if (win == focus_border.top || win == focus_border.bottom || win == focus_border.left || win == focus_border.right) { CSetColor (color_widget (0)); CRectangle (win, 0, 0, focus_border.width + 2, focus_border.height + 2); }}static int look_gtk_get_extra_window_spacing (void){ return 2;}static int look_gtk_get_focus_ring_size (void){ return 1;}static unsigned long look_gtk_get_button_flat_color (void){ return color_widget(12);}static int look_gtk_get_window_resize_bar_thickness (void){ return 0;}static int look_gtk_get_switch_size (void){ return FONT_PIX_PER_LINE + TEXT_RELIEF * 2 + 2 + 4;}static int look_gtk_get_fielded_textbox_hscrollbar_width (void){ return 12;}struct look look_gtk = { look_gtk_get_default_interwidget_spacing, look_gtk_menu_draw, look_gtk_get_menu_item_extents, look_gtk_render_menu_button, look_gtk_render_button, look_gtk_render_bar, look_gtk_render_raised_bevel, look_gtk_render_sunken_bevel, look_gtk_draw_hotkey_understroke, look_gtk_get_default_widget_font, look_gtk_render_text, look_gtk_render_window, look_gtk_render_scrollbar, look_gtk_get_scrollbar_size, look_gtk_init_scrollbar_icons, look_gtk_which_scrollbar_button, look_cool_scrollbar_handler, look_gtk_get_button_color, look_gtk_get_extra_window_spacing, look_cool_window_handler, look_gtk_get_focus_ring_size, look_gtk_get_button_flat_color, look_gtk_get_window_resize_bar_thickness, look_gtk_render_switch, look_gtk_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_gtk_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_gtk_render_fielded_textbox_tidbits, look_gtk_render_textbox_tidbits, look_gtk_get_fielded_textbox_hscrollbar_width, look_gtk_render_textinput_tidbits, look_gtk_render_passwordinput_tidbits, look_gtk_render_focus_border,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -