mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
1998-04-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.h: Added extern declarations for the want_transparent_icons and want_transparent_text variables. * gtrans.c (set_window_text): Now we use the new global variables want_transparent_icons and want_transparent_text to decide how to paint the pixmap and mask. The want_transparent_* variables can thus be configured for the smartness/speed of your X server when using shaped windows.
This commit is contained in:
parent
a2059d69a1
commit
1ff37554b8
@ -1,3 +1,14 @@
|
|||||||
|
1998-04-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||||
|
|
||||||
|
* gdesktop.h: Added extern declarations for the
|
||||||
|
want_transparent_icons and want_transparent_text variables.
|
||||||
|
|
||||||
|
* gtrans.c (set_window_text): Now we use the new global variables
|
||||||
|
want_transparent_icons and want_transparent_text to decide how to
|
||||||
|
paint the pixmap and mask. The want_transparent_* variables can
|
||||||
|
thus be configured for the smartness/speed of your X server when
|
||||||
|
using shaped windows.
|
||||||
|
|
||||||
Fri Apr 12 02:40:41 1998 Norbert Warmuth <k3190@fh-sw.de>
|
Fri Apr 12 02:40:41 1998 Norbert Warmuth <k3190@fh-sw.de>
|
||||||
|
|
||||||
* gwidget.c (x_create_input): return 1 if the widget has been
|
* gwidget.c (x_create_input): return 1 if the widget has been
|
||||||
|
@ -33,6 +33,10 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
/* gtrans.c */
|
/* gtrans.c */
|
||||||
|
|
||||||
|
extern int want_transparent_icons;
|
||||||
|
extern int want_transparent_text;
|
||||||
|
|
||||||
GtkWidget *create_transparent_text_window (char *file, char *text, int extra_events);
|
GtkWidget *create_transparent_text_window (char *file, char *text, int extra_events);
|
||||||
GtkWidget *make_transparent_window (char *file);
|
GtkWidget *make_transparent_window (char *file);
|
||||||
|
|
||||||
|
155
gnome/gtrans.c
155
gnome/gtrans.c
@ -10,14 +10,18 @@
|
|||||||
#include "gdesktop.h"
|
#include "gdesktop.h"
|
||||||
#include "gcache.h"
|
#include "gcache.h"
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
/* The spacing between the cute little icon and the text */
|
/* The spacing between the cute little icon and the text */
|
||||||
#define SPACING 2
|
#define SPACING 2
|
||||||
|
|
||||||
int want_transparent = 0;
|
|
||||||
|
|
||||||
/*
|
int want_transparent_icons = 1;
|
||||||
* Most of this code was yanked from the gtktooltips module in Gtk+.
|
int want_transparent_text = 0;
|
||||||
* I have tweaked it a bit for MC's purposes - Federico
|
|
||||||
|
|
||||||
|
/* Most of the word-wrapping code was yanked from the gtktooltips
|
||||||
|
* module in Gtk+. I have tweaked it a bit for MC's purposes
|
||||||
|
* - Federico
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct text_info {
|
struct text_info {
|
||||||
@ -178,7 +182,7 @@ set_window_text (GtkWidget *window, GdkImlibImage *im, char *text)
|
|||||||
GdkBitmap *im_mask;
|
GdkBitmap *im_mask;
|
||||||
struct text_info *ti;
|
struct text_info *ti;
|
||||||
GdkColor color;
|
GdkColor color;
|
||||||
GdkGC *gc;
|
GdkGC *p_gc, *m_gc;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
ti = layout_text (window, text);
|
ti = layout_text (window, text);
|
||||||
@ -186,60 +190,133 @@ set_window_text (GtkWidget *window, GdkImlibImage *im, char *text)
|
|||||||
width = MAX (ti->width, im->rgb_width);
|
width = MAX (ti->width, im->rgb_width);
|
||||||
height = im->rgb_height + SPACING + ti->height;
|
height = im->rgb_height + SPACING + ti->height;
|
||||||
|
|
||||||
/* pixmap */
|
/* Create pixmap, mask, and gc's */
|
||||||
|
|
||||||
pixmap = gdk_pixmap_new (window->window, width, height, gdk_imlib_get_visual ()->depth);
|
pixmap = gdk_pixmap_new (window->window, width, height, gdk_imlib_get_visual ()->depth);
|
||||||
|
|
||||||
gc = gdk_gc_new (pixmap);
|
|
||||||
|
|
||||||
gdk_color_white (gdk_imlib_get_colormap (), &color);
|
|
||||||
gdk_gc_set_foreground (gc, &color);
|
|
||||||
gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, width, height);
|
|
||||||
|
|
||||||
im_pixmap = gdk_imlib_move_image (im);
|
|
||||||
gdk_window_copy_area (pixmap, gc,
|
|
||||||
(width - im->rgb_width) / 2,
|
|
||||||
0,
|
|
||||||
im_pixmap,
|
|
||||||
0, 0,
|
|
||||||
im->rgb_width, im->rgb_height);
|
|
||||||
gdk_imlib_free_pixmap (im_pixmap);
|
|
||||||
|
|
||||||
/* mask */
|
|
||||||
|
|
||||||
mask = gdk_pixmap_new (window->window, width, height, 1);
|
mask = gdk_pixmap_new (window->window, width, height, 1);
|
||||||
|
|
||||||
gc = gdk_gc_new (mask);
|
p_gc = gdk_gc_new (pixmap);
|
||||||
|
m_gc = gdk_gc_new (mask);
|
||||||
|
|
||||||
|
/* Fill mask with transparent */
|
||||||
|
|
||||||
color.pixel = 0;
|
color.pixel = 0;
|
||||||
gdk_gc_set_foreground (gc, &color);
|
gdk_gc_set_foreground (m_gc, &color);
|
||||||
gdk_draw_rectangle (mask, gc, TRUE, 0, 0, width, height);
|
gdk_draw_rectangle (mask,
|
||||||
|
m_gc,
|
||||||
|
TRUE,
|
||||||
|
0, 0,
|
||||||
|
width, height);
|
||||||
|
|
||||||
|
/* Icon */
|
||||||
|
|
||||||
|
im_pixmap = gdk_imlib_move_image (im);
|
||||||
im_mask = gdk_imlib_move_mask (im);
|
im_mask = gdk_imlib_move_mask (im);
|
||||||
|
|
||||||
|
if (!want_transparent_icons) {
|
||||||
|
/* black background */
|
||||||
|
|
||||||
|
gdk_color_black (gdk_imlib_get_colormap (), &color);
|
||||||
|
gdk_gc_set_foreground (p_gc, &color);
|
||||||
|
gdk_draw_rectangle (pixmap,
|
||||||
|
p_gc,
|
||||||
|
TRUE,
|
||||||
|
(width - im->rgb_width) / 2,
|
||||||
|
0,
|
||||||
|
im->rgb_width,
|
||||||
|
im->rgb_height);
|
||||||
|
|
||||||
|
/* opaque mask */
|
||||||
|
|
||||||
|
color.pixel = 1;
|
||||||
|
gdk_gc_set_foreground (m_gc, &color);
|
||||||
|
gdk_draw_rectangle (mask,
|
||||||
|
m_gc,
|
||||||
|
TRUE,
|
||||||
|
(width - im->rgb_width) / 2,
|
||||||
|
0,
|
||||||
|
im->rgb_width,
|
||||||
|
im->rgb_height);
|
||||||
|
} else if (im_mask)
|
||||||
|
gdk_draw_pixmap (mask,
|
||||||
|
m_gc,
|
||||||
|
im_mask,
|
||||||
|
0, 0,
|
||||||
|
(width - im->rgb_width) / 2,
|
||||||
|
0,
|
||||||
|
im->rgb_width,
|
||||||
|
im->rgb_height);
|
||||||
|
|
||||||
if (im_mask) {
|
if (im_mask) {
|
||||||
gdk_window_copy_area (mask, gc,
|
gdk_gc_set_clip_mask (p_gc, im_mask);
|
||||||
(width - im->rgb_width) / 2,
|
gdk_gc_set_clip_origin (p_gc, (width - im->rgb_width) / 2, 0);
|
||||||
0,
|
}
|
||||||
im_mask,
|
|
||||||
0, 0,
|
gdk_draw_pixmap (pixmap,
|
||||||
im->rgb_width, im->rgb_height);
|
p_gc,
|
||||||
|
im_pixmap,
|
||||||
|
0, 0,
|
||||||
|
(width - im->rgb_width) / 2,
|
||||||
|
0,
|
||||||
|
im->rgb_width,
|
||||||
|
im->rgb_height);
|
||||||
|
|
||||||
|
if (im_mask) {
|
||||||
|
gdk_gc_set_clip_mask (p_gc, NULL);
|
||||||
gdk_imlib_free_bitmap (im_mask);
|
gdk_imlib_free_bitmap (im_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdk_imlib_free_pixmap (im_pixmap);
|
||||||
|
|
||||||
color.pixel = 1;
|
/* Text */
|
||||||
gdk_gc_set_foreground (gc, &color);
|
|
||||||
paint_text (ti, mask, gc,
|
if (!want_transparent_text) {
|
||||||
|
/* black background */
|
||||||
|
|
||||||
|
gdk_color_black (gdk_imlib_get_colormap (), &color);
|
||||||
|
gdk_gc_set_foreground (p_gc, &color);
|
||||||
|
gdk_draw_rectangle (pixmap,
|
||||||
|
p_gc,
|
||||||
|
TRUE,
|
||||||
|
(width - ti->width) / 2,
|
||||||
|
im->rgb_height + SPACING,
|
||||||
|
ti->width,
|
||||||
|
ti->height);
|
||||||
|
|
||||||
|
/* opaque mask */
|
||||||
|
|
||||||
|
color.pixel = 1;
|
||||||
|
gdk_gc_set_foreground (m_gc, &color);
|
||||||
|
gdk_draw_rectangle (mask,
|
||||||
|
m_gc,
|
||||||
|
TRUE,
|
||||||
|
(width - ti->width) / 2,
|
||||||
|
im->rgb_height + SPACING,
|
||||||
|
ti->width,
|
||||||
|
ti->height);
|
||||||
|
} else {
|
||||||
|
color.pixel = 1;
|
||||||
|
gdk_gc_set_foreground (m_gc, &color);
|
||||||
|
paint_text (ti, mask, m_gc,
|
||||||
|
(width - ti->width) / 2,
|
||||||
|
im->rgb_height + SPACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
gdk_color_white (gdk_imlib_get_colormap (), &color);
|
||||||
|
gdk_gc_set_foreground (p_gc, &color);
|
||||||
|
paint_text (ti, pixmap, p_gc,
|
||||||
(width - ti->width) / 2,
|
(width - ti->width) / 2,
|
||||||
im->rgb_height + SPACING);
|
im->rgb_height + SPACING);
|
||||||
|
|
||||||
gdk_gc_destroy (gc);
|
/* Set contents of window */
|
||||||
|
|
||||||
/* set contents */
|
|
||||||
|
|
||||||
gtk_widget_set_usize (window, width, height);
|
gtk_widget_set_usize (window, width, height);
|
||||||
gdk_window_set_back_pixmap (window->window, pixmap, FALSE);
|
gdk_window_set_back_pixmap (window->window, pixmap, FALSE);
|
||||||
gdk_window_shape_combine_mask (window->window, mask, 0, 0);
|
gdk_window_shape_combine_mask (window->window, mask, 0, 0);
|
||||||
|
|
||||||
|
gdk_gc_destroy (p_gc);
|
||||||
|
gdk_gc_destroy (m_gc);
|
||||||
|
|
||||||
gdk_pixmap_unref (pixmap);
|
gdk_pixmap_unref (pixmap);
|
||||||
gdk_pixmap_unref (mask);
|
gdk_pixmap_unref (mask);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user