📄 scrollbar_paint.c
字号:
#ifndef lint#ifdef sccsstatic char sccsid[] = "@(#)scrollbar_paint.c 1.1 92/07/30 Copyr 1984 Sun Micro";#endif#endif/*************************************************************************//* scrollbar_paint.c *//* Copyright (c) 1985 by Sun Microsystems, Inc. *//*************************************************************************/#include <suntool/scrollbar_impl.h> static int paint_client, clear_client;static void paint_bar(), paint_border(), paint_client_pw();static void clear_bar(), paint_bubble();static void lock_bar(), unlock_bar();static void paint_v_arrow(), paint_h_arrow();/**************************************************************************//* patterns *//**************************************************************************/static short scrollbar_bar_pattern[8] = { 0x8080, 0x1010, 0x0202, 0x4040, 0x0808, 0x0101, 0x2020, 0x0404};mpr_static(scrollbar_mpr_for_sb_pattern, 16, sizeof(scrollbar_bar_pattern)/2, 1, scrollbar_bar_pattern); static short scrollbar_grey_pattern[16] = { 0xAAAA,0x5555,0xAAAA,0x5555,0xAAAA,0x5555,0xAAAA,0x5555, 0xAAAA,0x5555,0xAAAA,0x5555,0xAAAA,0x5555,0xAAAA,0x5555};mpr_static(scrollbar_mpr_for_grey_pattern, 16, 16, 1, scrollbar_grey_pattern);/**************************************************************************//* external procs *//**************************************************************************/scrollbar_paint(sb_client)Scrollbar sb_client;{ register bar_should_appear = FALSE; register bubble_should_appear = FALSE; register scrollbar_handle sb; sb = (scrollbar_handle)(LINT_CAST(sb_client)); if ((!sb) || (!sb->pixwin)) return 0; if (bar_always(sb) || ((sb == scrollbar_active_sb) && bar_active(sb))) bar_should_appear = TRUE; if (bubble_always(sb) || ((sb == scrollbar_active_sb) && bubble_active(sb))) bubble_should_appear = TRUE; lock_bar(sb); if (sb->bubble_modified || sb->attrs_modified) { if (bar_should_appear) paint_bar(sb); else clear_bar(sb); if (bubble_should_appear) paint_bubble(sb); } else if (bar_should_appear) { if (!sb->bar_painted) paint_bar(sb); if (bubble_should_appear) paint_bubble(sb); } else if (bubble_should_appear) { if (!sb->bar_painted && !sb->bubble_painted) paint_bubble(sb); else { clear_bar(sb); paint_bubble(sb); } } unlock_bar(sb); sb->bubble_modified = FALSE; sb->attrs_modified = FALSE; return 1;}scrollbar_paint_clear(sb_client)Scrollbar sb_client;{ scrollbar_handle sb; sb = (scrollbar_handle)(LINT_CAST(sb_client)); if ((!sb) || (!sb->pixwin)) return 0; lock_bar(sb); clear_bar(sb); if (bar_always(sb)) paint_bar(sb); if (bubble_always(sb)) paint_bubble(sb); unlock_bar(sb); sb->bubble_modified = FALSE; sb->attrs_modified = FALSE; return 1;}scrollbar_clear(sb_client)Scrollbar sb_client;{ scrollbar_handle sb; sb = (scrollbar_handle)(LINT_CAST(sb_client)); lock_bar(sb); clear_bar(sb); unlock_bar(sb);}scrollbar_paint_bubble(sb_client)Scrollbar sb_client;{ scrollbar_handle sb; sb = (scrollbar_handle)(LINT_CAST(sb_client)); lock_bar(sb); paint_bubble(sb); unlock_bar(sb);}scrollbar_clear_bubble(sb_client)Scrollbar sb_client;{ scrollbar_handle sb; sb = (scrollbar_handle)(LINT_CAST(sb_client)); lock_bar(sb); if (bar_always(sb) || ((sb == scrollbar_active_sb) && bar_active(sb))) paint_bar(sb); else clear_bar(sb); unlock_bar(sb);}scrollbar_repaint(sb_client, status) /* called by scrollbar_event.c */Scrollbar sb_client;int status;{ scrollbar_handle sb; sb = (scrollbar_handle)(LINT_CAST(sb_client)); if ((!sb) || (!sb->pixwin)) return 0; if (!(bar_active(sb) || bubble_active(sb))) return 0; lock_bar(sb); if (status == SCROLLBAR_OUTSIDE) { if (sb->bar_display_level == SCROLL_ALWAYS) paint_bar(sb); else { clear_bar(sb); if (bubble_always(sb)) paint_bubble(sb); } } else { if (bar_active(sb)) paint_bar(sb); if (bubble_active(sb) || (bubble_always(sb) && sb->bar_painted)) paint_bubble(sb); } unlock_bar(sb); return 0;}/**************************************************************************//* lock/unlock & cover for external interface *//**************************************************************************/static voidlock_bar(sb)scrollbar_handle sb;{ struct rect rect; (void)pw_get_region_rect(sb->pixwin, &rect); rect.r_left = rect.r_top = 0; (void)pw_lock(sb->pixwin, &rect); paint_client = clear_client = FALSE;}static voidunlock_bar(sb)scrollbar_handle sb;{ (void)pw_unlock(sb->pixwin); if (paint_client || clear_client) paint_client_pw(sb, paint_client);}static voidpaint_bar(sb)scrollbar_handle sb;{ register int x, y, w, h; if (sb->buttons && (!sb->buttons_painted || sb->attrs_modified)) sb->paint_buttons_proc(sb); if (sb->horizontal) { x = sb->button_length; y = 0; w = sb->rect.r_width - (2*sb->button_length); h = sb->rect.r_height; if (sb->border) { h--; if (sb->gravity == SCROLL_MAX) y++; } } else { x = 0; y = sb->button_length; w = sb->rect.r_width; h = sb->rect.r_height - (2*sb->button_length); if (sb->border) { w--; if (sb->gravity == SCROLL_MAX) x++; } } if (!sb->one_button_case) if (sb->bar_grey) (void)pw_replrop(sb->pixwin, x, y, w, h, PIX_SRC, &scrollbar_mpr_for_sb_pattern, 0, 0); else (void)pw_writebackground(sb->pixwin, x, y, w, h, PIX_CLR); if (sb->border && (!sb->border_painted || sb->attrs_modified)) paint_border(sb); sb->bar_painted = TRUE; sb->bubble_painted = FALSE;}static voidpaint_border(sb)scrollbar_handle sb;{ register int x, y, w, h; if (sb->horizontal) { x = sb->button_length; y = 0; w = sb->rect.r_width - (2*sb->button_length); h = 1; if (sb->gravity == SCROLL_MIN) y = sb->rect.r_height - 1; } else { x = 0; y = sb->button_length; w = 1; h = sb->rect.r_height - (2*sb->button_length); if (sb->gravity == SCROLL_MIN) x = sb->rect.r_width - 1; } if (!sb->one_button_case) (void)pw_vector(sb->pixwin, x, y, x+w-1, y+h-1, PIX_SET, 1); sb->border_painted = TRUE; paint_client = TRUE;}static voidpaint_client_pw(sb, paint_flag)scrollbar_handle sb;int paint_flag;{ struct rect rect; struct pixwin *client_pw = NULL; int x, y, h, w; /* now paint or clear the border on the end of the button if necessary */ (void)win_getsize(sb->client_windowfd, &rect); x = sb->rect.r_left; y = sb->rect.r_top; w = sb->rect.r_width; h = sb->rect.r_height; if (sb->horizontal) { if (sb->rect.r_left) { /* paint left edge */ client_pw++; x--; } else if (sb->rect.r_width != rect.r_width) { /* paint right edge */ client_pw++; x += w; } w = 1; } else { if (sb->rect.r_top) { /* paint top edge */ client_pw++; y--; } else if (sb->rect.r_height != rect.r_height) { /* paint bottom edge */ client_pw++; y += h; } h = 1; } if (client_pw) { client_pw = win_get_pixwin(sb->notify_client); if (paint_flag) (void)pw_vector(client_pw, x, y, x+w-1, y+h-1, PIX_SET, 1); else (void)pw_writebackground(client_pw, x, y, w, h, PIX_CLR); }}static voidclear_bar(sb)scrollbar_handle sb;{ (void)pw_writebackground(sb->pixwin, 0, 0, sb->rect.r_width, sb->rect.r_height, PIX_CLR); sb->bar_painted = FALSE; sb->bubble_painted = FALSE; sb->buttons_painted = FALSE; sb->border_painted = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -