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

📄 krell.c

📁 系统任务管理器
💻 C
📖 第 1 页 / 共 4 页
字号:
				gkrellm_draw_panel_layers(p);				}			}		else			if (b->cur_index == b->pressed_index)				set_button_index(b, b->saved_index, 1);		}	return FALSE;	}static gintcb_decal_button_enter(GtkWidget *widget, GdkEventButton *ev, GkrellmPanel *p)	{	GList				*list;	GkrellmDecalbutton	*b;	if (ev->type != GDK_ENTER_NOTIFY)	/* I'm connected to "event" */		return FALSE;	for (list = p->button_list; list; list = list->next)		{		b = (GkrellmDecalbutton *) list->data;		if (b->type != AUTO_HIDE_BUTTON || ! b->sensitive)			continue;		b->decal->state = DS_VISIBLE;		set_button_index(b, 0, 0);		b->decal->modified = TRUE;		p->need_decal_overlap_check = TRUE;		gkrellm_draw_panel_layers(b->panel);		}	return FALSE;	}voidgkrellm_set_decal_button_index(GkrellmDecalbutton *b, gint index)	{	if (!b)		return;	if (b->cur_index == b->pressed_index)		b->saved_index = index;	/* Throw away old save */	else		set_button_index(b, index, 0);	}GkrellmDecalbutton *gkrellm_decal_is_button(GkrellmDecal *d)	{	GkrellmPanel		*p;	GkrellmDecalbutton	*b;	GList				*list;	if ((p = (GkrellmPanel *) d->panel) == NULL)		return NULL;	for (list = p->button_list; list; list = list->next)		{		b = (GkrellmDecalbutton *) list->data;		if (b->decal == d)			return b;		}	return NULL;	}voidgkrellm_destroy_button(GkrellmDecalbutton *b)	{	GkrellmPanel	*p;	if (!b)		return;	p = b->panel;	if (p && b->decal)		_remove_decal(p, b->decal);	if (b->decal)		_destroy_decal(b->decal);	remove_from_button_list(p, b);	}voidgkrellm_set_in_button_callback(GkrellmDecalbutton *b,			gint (*func)(), gpointer data)	{	if (!b)		return;	b->cb_in_button = func;	b->in_button_data = data;	}voidgkrellm_decal_button_connect(GkrellmDecalbutton *b, void (*func)(), void *data)	{	if (!b)		return;	b->data = data;	b->cb_button_click = func;	}voidgkrellm_decal_button_right_connect(GkrellmDecalbutton *b,				void (*func)(), void *data)	{	if (!b)		return;	b->right_data = data;	b->cb_button_right_click = func;	}voidgkrellm_panel_button_signals_connect(GkrellmPanel *p)	{	/* I want DecalButton event handlers to be called before any monitor	|  handlers, but DecalButtons will be recreated at theme changes and	|  thus its handlers will be after panel handlers. So, connect to	|  "event" which is called first, and check for the right event in	|  the callback.	|  There is only one event handler per signal per panel.  Buttons do	|  not have their own event box so they may be efficiently animated.	*/	if (   !p || p->button_signals_connected		|| !p->button_list || !p->drawing_area	   )		return;	p->id_press = g_signal_connect(G_OBJECT(p->drawing_area),				"event", G_CALLBACK(cb_decal_button_press), p);	p->id_release = g_signal_connect(G_OBJECT(p->drawing_area),				"event", G_CALLBACK(cb_decal_button_release), p);	p->id_enter = g_signal_connect(G_OBJECT(p->drawing_area),				"event", G_CALLBACK(cb_decal_button_enter), p);	p->id_leave = g_signal_connect(G_OBJECT(p->drawing_area),				"event", G_CALLBACK(cb_decal_button_leave), p);	p->button_signals_connected = TRUE;	}  /* Make an existing decal into a decal button.  The decal should already  |  be created and be in the panel's decal list.  */GkrellmDecalbutton *gkrellm_make_decal_button(GkrellmPanel *p, GkrellmDecal *d, void (*func)(),			void *data, gint cur_index, gint pressed_index)	{	GkrellmDecalbutton	*b;	if (!p || !d)		return NULL;	b = g_new0(GkrellmDecalbutton, 1);	b->panel = p;	b->decal = d;	b->pressed_index = pressed_index;	b->data = data;	b->cb_button_click = func;	b->cb_in_button = gkrellm_in_button;	b->in_button_data = NULL;	b->sensitive = TRUE;	set_button_index(b, cur_index, 0);	p->button_list = g_list_append(p->button_list, b);	gkrellm_panel_button_signals_connect(p);	p->need_decal_overlap_check = TRUE;	return b;	}GkrellmDecalbutton *gkrellm_make_overlay_button(GkrellmPanel *p, void (*func)(), void *data,				gint x, gint y, gint w, gint h,				GkrellmPiximage *normal_piximage,				GkrellmPiximage *pressed_piximage)	{	GtkWidget			*top_win;	GkrellmDecalbutton	*b;	GkrellmDecal		*d;	GdkPixmap			*pm = NULL, *pixmap;	GdkBitmap			*m = NULL, *mask;	if (!p)		return NULL;	top_win = gkrellm_get_top_window();	if (x < 0)		{		w -= x;		x = 0;		}	if (y < 0)		{		h -= y;		y = 0;		}	if (x + w > _GK.chart_width)		w = _GK.chart_width - x;	if (p->h > 0 && y + h > p->h)		h = p->h - y;	if (h < 2)		h = 2;	if (w < 4)		w = 4;	pixmap = gdk_pixmap_new(top_win->window, w, 2 * h, -1);	mask = gdk_pixmap_new(top_win->window, w, 2 * h, 1);	if (normal_piximage && pressed_piximage)		{		gkrellm_scale_piximage_to_pixmap(normal_piximage, &pm, &m, w, h);		gdk_draw_drawable(pixmap, _GK.draw1_GC, pm, 0, 0, 0, 0, w, h);		if (m)			gdk_draw_drawable(mask, _GK.bit1_GC, m, 0, 0, 0, 0, w, h);		else			gdk_draw_rectangle(mask, _GK.bit1_GC, TRUE, 0, 0, w, h);		gkrellm_free_pixmap(&pm);		gkrellm_free_bitmap(&m);		gkrellm_scale_piximage_to_pixmap(pressed_piximage, &pm, &m, w, h);		gdk_draw_drawable(pixmap, _GK.draw1_GC, pm, 0, 0, 0, h, w, h);		if (m)			gdk_draw_drawable(mask, _GK.bit1_GC, m, 0, 0, 0, h, w, h);		else			gdk_draw_rectangle(mask, _GK.bit1_GC, TRUE, 0, h, w, h);		gkrellm_free_pixmap(&pm);		gkrellm_free_bitmap(&m);		}	else	/* Make a default frame. */		{		GdkColor	gray0, gray1;		GdkColormap	*cmap;		cmap = gdk_colormap_get_system();		gdk_color_parse("gray65", &gray0);		gdk_color_parse("gray100", &gray1);		gdk_colormap_alloc_color(cmap, &gray0, FALSE, TRUE);		gdk_colormap_alloc_color(cmap, &gray1, FALSE, TRUE);		gdk_gc_set_foreground(_GK.draw1_GC, &gray1);		gdk_draw_line(pixmap, _GK.draw1_GC, 0, 0, w - 1, 0);				gdk_draw_line(pixmap, _GK.draw1_GC, 0, 0, 0, h - 1);				gdk_draw_line(pixmap, _GK.draw1_GC, 0, 2 * h - 1, w - 1, 2 * h - 1);		gdk_draw_line(pixmap, _GK.draw1_GC, w - 1, 2 * h - 1, w - 1, h);		gdk_gc_set_foreground(_GK.draw1_GC, &gray0);		gdk_draw_line(pixmap, _GK.draw1_GC, 0, h - 1, w - 1, h - 1);				gdk_draw_line(pixmap, _GK.draw1_GC, w - 1, h - 1, w - 1, 0);				gdk_draw_line(pixmap, _GK.draw1_GC, 0, h, w - 1, h);				gdk_draw_line(pixmap, _GK.draw1_GC, 0, h, 0, 2 * h - 1);				gdk_draw_rectangle(mask, _GK.bit1_GC, TRUE, 0, 0, w, 2 * h);				gdk_draw_rectangle(mask, _GK.bit0_GC, TRUE, 1, 1, w - 2, h - 2);		gdk_draw_rectangle(mask, _GK.bit0_GC, TRUE, 1, h + 1, w - 2, h - 2);		gdk_colormap_free_colors(cmap, &gray0, 1);		gdk_colormap_free_colors(cmap, &gray1, 1);		}	d = gkrellm_create_decal_pixmap(p, pixmap, mask, 2, NULL, x, y);	d->flags |= (DF_LOCAL_PIXMAPS | DF_OVERLAY_PIXMAPS);	d->state = DS_INVISIBLE;	b = gkrellm_make_decal_button(p, d, func, data, 0, 1);	b->type = AUTO_HIDE_BUTTON;	return b;	}GkrellmDecalbutton *gkrellm_put_decal_in_panel_button(GkrellmPanel *p, GkrellmDecal *d,			void (*func)(), void *data, GkrellmMargin *margin_pad)	{	GkrellmDecalbutton	*b;	GkrellmBorder		*border;	GkrellmMargin		*margin;	gint				x, y, w, h, a;	if (!p || !d)		return NULL;	border = &_GK.button_panel_border;	margin = margin_pad ? margin_pad : &zero_margin;	x = d->x - border->left - margin->left;	a = d->x + d->w + border->right + margin->right;	w = a - x;	y = d->y - border->top - margin->top;	a = d->y + d->h + border->bottom + margin->bottom;	h = a - y;	b = gkrellm_make_overlay_button(p, func, data, x, y, w, h,				_GK.button_panel_out_piximage, _GK.button_panel_in_piximage);	return b;	}GkrellmDecalbutton *gkrellm_put_decal_in_meter_button(GkrellmPanel *p, GkrellmDecal *d,			void (*func)(), void *data, GkrellmMargin *margin_pad)	{	GkrellmDecalbutton	*b;	GkrellmBorder		*border;	GkrellmMargin		*margin;	gint				x, y, w, h, a;	if (!p || !d)		return NULL;	border = &_GK.button_meter_border;	margin = margin_pad ? margin_pad : &zero_margin;	x = d->x - border->left - margin->left;	a = d->x + d->w + border->right + margin->right;	w = a - x;	y = d->y - border->top - margin->top;	a = d->y + d->h + border->bottom + margin->bottom;	h = a - y;	b = gkrellm_make_overlay_button(p, func, data, x, y, w, h,				_GK.button_meter_out_piximage, _GK.button_meter_in_piximage);	return b;	}static GkrellmDecalbutton *put_label_in_button(GkrellmPanel *p, void (*func)(), void *data, gint type,			gint pad)	{	GkrellmDecalbutton	*b;	GkrellmLabel		*lbl;	GkrellmMargin		*m;	GkrellmPiximage		*normal_piximage, *pressed_piximage;	GkrellmBorder		*style_border, *fr_border;	gint				x, y, w, h;	if (!p || p->h == 0)		return NULL;	fr_border = (type == METER_PANEL_TYPE) ? &_GK.button_meter_border										: &_GK.button_panel_border;	normal_piximage = (type == METER_PANEL_TYPE)			? _GK.button_meter_out_piximage : _GK.button_panel_out_piximage;	pressed_piximage = (type == METER_PANEL_TYPE)			? _GK.button_meter_in_piximage : _GK.button_panel_in_piximage;	/* If no panel label, put the whole panel in the button.	*/	if ((lbl = p->label) == NULL || lbl->string == NULL || lbl->position < 0)		{		m = gkrellm_get_style_margins(p->style);		style_border = p->style ? &p->style->border : &zero_border;		x = 0 + m->left;		y = 0 + style_border->top - fr_border->top;		w = p->w - x - m->right;		h = p->h - y - style_border->bottom + fr_border->bottom;		}	else		{		x = lbl->x_panel - fr_border->left - pad;		y = lbl->y_panel - fr_border->top;		w = lbl->width + fr_border->left + fr_border->right + 2 * pad;		h = lbl->height + (p->textstyle->effect ? 1 : 0)				+ fr_border->top + fr_border->bottom;		}	b = gkrellm_make_overlay_button(p, func, data, x, y, w, h,					normal_piximage, pressed_piximage);	return b;	}GkrellmDecalbutton *gkrellm_put_label_in_panel_button(GkrellmPanel *p, void (*func)(), void *data,				gint pad)	{	GkrellmDecalbutton	*b;	b = put_label_in_button(p, func, data, CHART_PANEL_TYPE, pad);	return b;	}GkrellmDecalbutton *gkrellm_put_label_in_meter_button(GkrellmPanel *p, void (*func)(), void *data,				gint pad)	{	GkrellmDecalbutton	*b;	b = put_label_in_button(p, func, data, METER_PANEL_TYPE, pad);	return b;	}GkrellmDecalbutton *gkrellm_make_scaled_button(GkrellmPanel *p, GkrellmPiximage *im,			void (*func)(), void *data,			gboolean auto_hide, gboolean set_default_border,			gint depth, gint cur_index, gint pressed_index,			gint x, gint y, gint w, gint h)	{	GtkWidget			*top_win;	GkrellmDecalbutton	*b;	GkrellmDecal		*d;	GkrellmBorder		*bdr;	GdkPixmap			*pixmap;	GdkBitmap			*mask;	if (!p)		return NULL;	if (!im)		{		im = _GK.decal_button_piximage;		depth = 2;		cur_index = 0;		pressed_index = 1;		}	if (depth < 2)		depth = 2;	if (w < 0)		w = gkrellm_chart_width();	else		{		if (w == 0)			w = gdk_pixbuf_get_width(im->pixbuf);		if ((w = w * _GK.theme_scale / 100) < 2)			w = 2;		}	if (h < 0)		h = p->h;	else		{		if (h == 0)			h = gdk_pixbuf_get_height(im->pixbuf) / depth;		if ((h = h * _GK.theme_scale / 100) < 2)			h = 2;		}	top_win = gkrellm_get_top_window();	pixmap = gdk_pixmap_new(top_win->window, w, depth * h, -1);	mask = gdk_pixmap_new(top_win->window, w, depth * h, 1);	if (set_default_border)		{		bdr = &im->border;		bdr->left = bdr->right = bdr->top = bdr->bottom = 1;		}	gkrellm_scale_piximage_to_pixmap(im, &pixmap, &mask, w, depth * h);	d = gkrellm_create_decal_pixmap(p, pixmap, mask, depth, NULL, x, y);	d->flags |= DF_LOCAL_PIXMAPS;	b = gkrellm_make_decal_button(p, d, func, data, cur_index, pressed_index);	if (auto_hide)		{		d->state = DS_INVISIBLE;		b->type = AUTO_HIDE_BUTTON;		}	return b;	}GkrellmDecal *gkrellm_make_scaled_decal_pixmap(GkrellmPanel *p, GkrellmPiximage *im,			GkrellmStyle *style, gint depth,			gint x, gint y, gint w, gint h)	{	GtkWidget		*top_win;	GdkPixmap		*pixmap;	GdkBitmap		*mask;	GkrellmMargin	*m;	GkrellmDecal	*d;	if (!im)		return NULL;	top_win = gkrellm_get_top_window();	d = (GkrellmDecal *) g_new0(GkrellmDecal, 1);	if (p)		{		p->decal_list = g_list_append(p->decal_list, d);		p->need_decal_overlap_check = TRUE;		}	d->panel = (gpointer) p;	if (depth < 1)		depth = 1;	if (   w < 1		&& (w = gdk_pixbuf_get_width(im->pixbuf) * _GK.theme_scale / 100) < 1	   )		w = 1;	d->w = w;	if (h < 1)		h = gdk_pixbuf_get_height(im->pixbuf) / depth * _GK.theme_scale / 100;	if (h < 1)		h = 1;	d->h = h;	pixmap = gdk_pixmap_new(top_win->window, d->w, d->h * depth, -1);	mask = gdk_pixmap_new(top_win->window, d->w, d->h * depth, 1);	gkrellm_scale_piximage_to_pixmap(im, &pixmap, &mask, d->w, d->h * depth);	d->x = x;	m = gkrellm_get_style_margins(style);	if (d->x < 0 && style)		{		if (   style->label_position < 50			&& style->label_position != GKRELLM_LABEL_NONE		   )			d->x = _GK.chart_width - d->w - m->right;		else			d->x = m->left;		}	d->y = y;	if (d->y < 0)		d->y = m->top;	d->pixmap = pixmap;	d->mask   = mask;	d->stencil = gdk_pixmap_new(top_win->window, d->w, d->h, 1);	d->value = -1;		/* Force initial draw */	d->flags = DF_LOCAL_PIXMAPS;	d->state = DS_VISIBLE;	return d;	}

⌨️ 快捷键说明

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