1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "cursorutil.h"
|
1999-01-18 01:03:54 +08:00
|
|
|
#include "dialog_handler.h"
|
1999-01-11 07:36:29 +08:00
|
|
|
#include "gdisplay.h" /* for gdisplay_*_override_cursor() */
|
1999-05-05 18:46:00 +08:00
|
|
|
#include "../cursors/mouse1"
|
|
|
|
#include "../cursors/mouse1msk"
|
|
|
|
#include "../cursors/mouse1_p"
|
|
|
|
#include "../cursors/mouse1_pmsk"
|
|
|
|
#include "../cursors/mouse1_m"
|
|
|
|
#include "../cursors/mouse1_mmsk"
|
|
|
|
#include "../cursors/bigcirc"
|
|
|
|
#include "../cursors/bigcircmsk"
|
1999-05-13 19:12:32 +08:00
|
|
|
#include "../cursors/dropper"
|
|
|
|
#include "../cursors/droppermsk"
|
1999-05-14 06:53:40 +08:00
|
|
|
#include "../cursors/mouse1_ap"
|
|
|
|
#include "../cursors/mouse1_apmsk"
|
|
|
|
#include "../cursors/mouse1_cp"
|
|
|
|
#include "../cursors/mouse1_cpmsk"
|
|
|
|
#include "../cursors/mouse1_mm"
|
|
|
|
#include "../cursors/mouse1_mmmsk"
|
|
|
|
#include "../cursors/mouse1_sel"
|
|
|
|
#include "../cursors/mouse1_selmsk"
|
|
|
|
#include "../cursors/mouse1_selm"
|
|
|
|
#include "../cursors/mouse1_selmmsk"
|
|
|
|
#include "../cursors/mouse1_selp"
|
|
|
|
#include "../cursors/mouse1_selpmsk"
|
1999-05-05 17:10:35 +08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char *bits;
|
|
|
|
unsigned char *mask_bits;
|
|
|
|
int width, height;
|
|
|
|
int x_hot, y_hot;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
} BM_Cursor;
|
|
|
|
|
|
|
|
static BM_Cursor gimp_cursors[] =
|
|
|
|
/* these have to match up with the enum in cursorutil.h */
|
|
|
|
{
|
|
|
|
{ mouse1_bits, mouse1msk_bits, mouse1_width, mouse1_height,
|
|
|
|
mouse1_x_hot, mouse1_y_hot, NULL},
|
|
|
|
{ mouse1_p_bits, mouse1_pmsk_bits, mouse1_p_width, mouse1_p_height,
|
|
|
|
mouse1_p_x_hot, mouse1_p_y_hot, NULL},
|
|
|
|
{ mouse1_m_bits, mouse1_mmsk_bits, mouse1_m_width, mouse1_m_height,
|
|
|
|
mouse1_m_x_hot, mouse1_m_y_hot, NULL},
|
|
|
|
{ bigcirc_bits, bigcircmsk_bits, bigcirc_width, bigcirc_height,
|
|
|
|
bigcirc_x_hot, bigcirc_y_hot, NULL},
|
1999-05-13 19:12:32 +08:00
|
|
|
{ dropper_bits, droppermsk_bits, dropper_width, dropper_height,
|
|
|
|
dropper_x_hot, dropper_y_hot, NULL},
|
1999-05-14 06:53:40 +08:00
|
|
|
{ mouse1_ap_bits, mouse1_apmsk_bits, mouse1_ap_width, mouse1_ap_height,
|
|
|
|
mouse1_ap_x_hot, mouse1_ap_y_hot, NULL},
|
|
|
|
{ mouse1_cp_bits, mouse1_cpmsk_bits, mouse1_cp_width, mouse1_cp_height,
|
|
|
|
mouse1_cp_x_hot, mouse1_cp_y_hot, NULL},
|
|
|
|
{ mouse1_mm_bits, mouse1_mmmsk_bits, mouse1_mm_width, mouse1_mm_height,
|
|
|
|
mouse1_mm_x_hot, mouse1_mm_y_hot, NULL},
|
|
|
|
{ mouse1_selp_bits, mouse1_selpmsk_bits, mouse1_selp_width, mouse1_selp_height,
|
|
|
|
mouse1_selp_x_hot, mouse1_selp_y_hot, NULL},
|
|
|
|
{ mouse1_selm_bits, mouse1_selmmsk_bits, mouse1_selm_width, mouse1_selm_height,
|
|
|
|
mouse1_selm_x_hot, mouse1_selm_y_hot, NULL},
|
|
|
|
{ mouse1_sel_bits, mouse1_selmsk_bits, mouse1_sel_width, mouse1_sel_height,
|
|
|
|
mouse1_sel_x_hot, mouse1_sel_y_hot, NULL},
|
1999-05-05 17:10:35 +08:00
|
|
|
};
|
|
|
|
|
1999-01-11 07:36:29 +08:00
|
|
|
|
1999-01-18 01:03:54 +08:00
|
|
|
|
1999-01-11 07:36:29 +08:00
|
|
|
extern GSList* display_list; /* It's in gdisplay.c, FYI */
|
1999-01-18 01:03:54 +08:00
|
|
|
static gboolean pending_removebusy = FALSE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-05-05 17:10:35 +08:00
|
|
|
static void
|
|
|
|
create_cursor(BM_Cursor *bmcursor)
|
|
|
|
{
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkPixmap *pixmapmsk;
|
|
|
|
GdkColor fg, bg;
|
|
|
|
|
|
|
|
/* should have a way to configure the mouse colors */
|
|
|
|
gdk_color_parse("#FFFFFF", &bg);
|
|
|
|
gdk_color_parse("#000000", &fg);
|
|
|
|
|
|
|
|
pixmap = gdk_bitmap_create_from_data (NULL, bmcursor->bits,
|
|
|
|
bmcursor->width, bmcursor->height);
|
|
|
|
g_return_if_fail(pixmap != NULL);
|
|
|
|
|
|
|
|
pixmapmsk = gdk_bitmap_create_from_data (NULL, bmcursor->mask_bits,
|
|
|
|
bmcursor->width,
|
|
|
|
bmcursor->height);
|
|
|
|
g_return_if_fail(pixmapmsk != NULL);
|
|
|
|
|
1999-05-05 18:46:00 +08:00
|
|
|
bmcursor->cursor = gdk_cursor_new_from_pixmap (pixmap, pixmapmsk, &fg, &bg,
|
|
|
|
bmcursor->x_hot,
|
|
|
|
bmcursor->y_hot);
|
|
|
|
g_return_if_fail (bmcursor->cursor != NULL);
|
1999-05-05 17:10:35 +08:00
|
|
|
}
|
|
|
|
|
1999-05-13 19:12:32 +08:00
|
|
|
static void
|
1999-05-05 17:10:35 +08:00
|
|
|
gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
g_return_if_fail (curtype < GIMP_LAST_CURSOR_ENTRY);
|
1999-05-13 19:12:32 +08:00
|
|
|
curtype -= GIMP_MOUSE1_CURSOR;
|
1999-05-05 17:10:35 +08:00
|
|
|
if (!gimp_cursors[(int)curtype].cursor)
|
1999-05-05 18:46:00 +08:00
|
|
|
create_cursor (&gimp_cursors[(int)curtype]);
|
1999-05-05 17:10:35 +08:00
|
|
|
cursor = gimp_cursors[(int)curtype].cursor;
|
|
|
|
gdk_window_set_cursor (win, cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
|
|
|
change_win_cursor (win, cursortype)
|
|
|
|
GdkWindow *win;
|
|
|
|
GdkCursorType cursortype;
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
1999-05-13 19:12:32 +08:00
|
|
|
|
|
|
|
if (cursortype > GDK_LAST_CURSOR)
|
|
|
|
{
|
|
|
|
gimp_change_win_cursor(win, (GimpCursorType)cursortype);
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
cursor = gdk_cursor_new (cursortype);
|
|
|
|
gdk_window_set_cursor (win, cursor);
|
|
|
|
gdk_cursor_destroy (cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
unset_win_cursor (win)
|
|
|
|
GdkWindow *win;
|
|
|
|
{
|
|
|
|
gdk_window_set_cursor (win, NULL);
|
|
|
|
}
|
|
|
|
|
1999-01-18 01:03:54 +08:00
|
|
|
void
|
|
|
|
gimp_add_busy_cursors_until_idle (void)
|
|
|
|
{
|
|
|
|
if (!pending_removebusy)
|
|
|
|
{
|
|
|
|
gimp_add_busy_cursors();
|
|
|
|
gtk_idle_add_priority (GTK_PRIORITY_HIGH,
|
|
|
|
gimp_remove_busy_cursors, NULL);
|
|
|
|
pending_removebusy = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-11 07:36:29 +08:00
|
|
|
void
|
|
|
|
gimp_add_busy_cursors (void)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
GSList *list = display_list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-01-18 01:03:54 +08:00
|
|
|
/* Canvases */
|
1999-01-11 07:36:29 +08:00
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
gdisp = (GDisplay *) list->data;
|
1999-05-05 18:46:00 +08:00
|
|
|
gdisplay_install_override_cursor (gdisp, GDK_WATCH);
|
1999-01-11 07:36:29 +08:00
|
|
|
|
|
|
|
list = g_slist_next (list);
|
|
|
|
}
|
1999-01-18 01:03:54 +08:00
|
|
|
|
|
|
|
/* Dialogs */
|
|
|
|
dialog_idle_all();
|
|
|
|
|
1999-01-11 07:36:29 +08:00
|
|
|
gdk_flush();
|
|
|
|
}
|
1999-01-18 01:03:54 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
gimp_remove_busy_cursors (gpointer data)
|
1999-01-11 07:36:29 +08:00
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
GSList *list = display_list;
|
|
|
|
|
1999-01-18 01:03:54 +08:00
|
|
|
/* Canvases */
|
1999-01-11 07:36:29 +08:00
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
gdisp = (GDisplay *) list->data;
|
1999-05-05 18:46:00 +08:00
|
|
|
gdisplay_remove_override_cursor (gdisp);
|
1999-01-11 07:36:29 +08:00
|
|
|
|
|
|
|
list = g_slist_next (list);
|
|
|
|
}
|
1999-01-18 01:03:54 +08:00
|
|
|
|
|
|
|
/* Dialogs */
|
|
|
|
dialog_unidle_all();
|
|
|
|
|
|
|
|
pending_removebusy = FALSE;
|
|
|
|
|
|
|
|
return 0;
|
1999-01-11 07:36:29 +08:00
|
|
|
}
|
1999-05-05 18:46:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|