2004-06-22 22:48:33 +04:00
|
|
|
/*
|
2006-11-27 20:13:24 +03:00
|
|
|
* Copyright 2006 Daniel Silverstone <dsilvers@digital-scurf.org>
|
2006-08-16 01:29:20 +04:00
|
|
|
* Copyright 2006 Rob Kendrick <rjek@rjek.com>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf 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, see <http://www.gnu.org/licenses/>.
|
2004-06-22 22:48:33 +04:00
|
|
|
*/
|
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "gtk/gtk_window.h"
|
|
|
|
#include "desktop/browser.h"
|
2007-08-07 07:55:18 +04:00
|
|
|
#include "desktop/options.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "gtk/gtk_gui.h"
|
|
|
|
#include "gtk/gtk_scaffolding.h"
|
|
|
|
#include "gtk/gtk_plotters.h"
|
|
|
|
#include "gtk/gtk_schedule.h"
|
2006-11-27 20:13:24 +03:00
|
|
|
#undef NDEBUG
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
2006-11-27 20:13:24 +03:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <assert.h>
|
2004-06-22 22:48:33 +04:00
|
|
|
|
|
|
|
struct gui_window {
|
2006-11-27 20:13:24 +03:00
|
|
|
/* All gui_window objects have an ultimate scaffold */
|
|
|
|
nsgtk_scaffolding *scaffold;
|
|
|
|
/* A gui_window is the rendering of a browser_window */
|
|
|
|
struct browser_window *bw;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* These are the storage for the rendering */
|
2006-08-16 01:29:20 +04:00
|
|
|
int caretx, carety, careth;
|
|
|
|
gui_pointer_shape current_pointer;
|
|
|
|
int last_x, last_y;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Within GTK, a gui_window is a scrolled window
|
|
|
|
* with a viewport inside
|
|
|
|
* with a gtkfixed in that
|
|
|
|
* with a drawing area in that
|
|
|
|
* The scrolled window is optional and only chosen
|
|
|
|
* for frames which need it. Otherwise we just use
|
|
|
|
* a viewport.
|
|
|
|
*/
|
|
|
|
GtkScrolledWindow *scrolledwindow;
|
|
|
|
GtkViewport *viewport;
|
|
|
|
GtkFixed *fixed;
|
2006-08-16 01:29:20 +04:00
|
|
|
GtkDrawingArea *drawing_area;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Keep gui_windows in a list for cleanup later */
|
|
|
|
struct gui_window *next, *prev;
|
2006-03-26 21:22:29 +04:00
|
|
|
};
|
|
|
|
|
2006-08-18 00:03:28 +04:00
|
|
|
static struct gui_window *window_list = 0; /**< first entry in win list*/
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
static wchar_t gdkkey_to_nskey(GdkEventKey *);
|
2006-11-27 20:13:24 +03:00
|
|
|
static void nsgtk_gui_window_attach_child(struct gui_window *parent,
|
|
|
|
struct gui_window *child);
|
|
|
|
/* Methods which apply only to a gui_window */
|
2006-08-16 01:29:20 +04:00
|
|
|
static gboolean nsgtk_window_expose_event(GtkWidget *, GdkEventExpose *,
|
2006-11-27 20:13:24 +03:00
|
|
|
gpointer);
|
2006-08-16 01:29:20 +04:00
|
|
|
static gboolean nsgtk_window_motion_notify_event(GtkWidget *, GdkEventMotion *,
|
|
|
|
gpointer);
|
|
|
|
static gboolean nsgtk_window_button_press_event(GtkWidget *, GdkEventButton *,
|
|
|
|
gpointer);
|
|
|
|
static gboolean nsgtk_window_keypress_event(GtkWidget *, GdkEventKey *,
|
|
|
|
gpointer);
|
|
|
|
static gboolean nsgtk_window_size_allocate_event(GtkWidget *, GtkAllocation *,
|
|
|
|
gpointer);
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Other useful bits */
|
|
|
|
static void nsgtk_redraw_caret(struct gui_window *g);
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2007-09-29 03:54:30 +04:00
|
|
|
static GdkCursor *nsgtk_create_menu_cursor(void);
|
2004-06-22 22:48:33 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
|
2006-08-18 00:03:28 +04:00
|
|
|
{
|
2006-11-27 20:13:24 +03:00
|
|
|
return g->scaffold;
|
2006-08-18 00:03:28 +04:00
|
|
|
}
|
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
struct browser_window *nsgtk_get_browser_for_gui(struct gui_window *g)
|
2006-06-02 11:48:13 +04:00
|
|
|
{
|
2006-11-27 20:13:24 +03:00
|
|
|
return g->bw;
|
|
|
|
}
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
float nsgtk_get_scale_for_gui(struct gui_window *g)
|
|
|
|
{
|
2007-08-07 07:55:18 +04:00
|
|
|
return g->bw->scale;
|
2006-06-02 11:48:13 +04:00
|
|
|
}
|
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Create a gui_window */
|
|
|
|
struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|
|
|
struct browser_window *clone)
|
2006-07-14 15:52:51 +04:00
|
|
|
{
|
2006-11-27 20:13:24 +03:00
|
|
|
struct gui_window *g; /**< what we're creating to return */
|
|
|
|
GtkPolicyType scrollpolicy;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
g = malloc(sizeof(*g));
|
2007-04-30 06:31:38 +04:00
|
|
|
if (!g) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
LOG(("Creating gui window %p for browser window %p", g, bw));
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
g->bw = bw;
|
|
|
|
g->current_pointer = GUI_POINTER_DEFAULT;
|
|
|
|
if (clone != NULL)
|
2007-08-07 07:55:18 +04:00
|
|
|
bw->scale = clone->scale;
|
2006-11-27 20:13:24 +03:00
|
|
|
else
|
2007-08-07 07:55:18 +04:00
|
|
|
bw->scale = (float) option_scale / 100;
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
g->careth = 0;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Attach ourselves to the list (push_top) */
|
|
|
|
if (window_list)
|
|
|
|
window_list->prev = g;
|
|
|
|
g->next = window_list;
|
|
|
|
g->prev = NULL;
|
|
|
|
window_list = g;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
if (bw->parent != NULL) {
|
|
|
|
/* Find our parent's scaffolding */
|
|
|
|
g->scaffold = bw->parent->window->scaffold;
|
|
|
|
} else {
|
|
|
|
/* Now construct and attach a scaffold */
|
|
|
|
g->scaffold = nsgtk_new_scaffolding(g);
|
|
|
|
}
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Construct our primary elements */
|
|
|
|
g->fixed = GTK_FIXED(gtk_fixed_new());
|
|
|
|
g->drawing_area = GTK_DRAWING_AREA(gtk_drawing_area_new());
|
|
|
|
gtk_fixed_put(g->fixed, GTK_WIDGET(g->drawing_area), 0, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(g->fixed), 0);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
if (bw->parent != NULL ) {
|
|
|
|
g->scrolledwindow = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
|
2007-08-08 20:16:03 +04:00
|
|
|
gtk_scrolled_window_add_with_viewport(g->scrolledwindow,
|
2006-11-27 20:13:24 +03:00
|
|
|
GTK_WIDGET(g->fixed));
|
|
|
|
gtk_scrolled_window_set_shadow_type(g->scrolledwindow,
|
|
|
|
GTK_SHADOW_NONE);
|
2007-02-10 05:21:32 +03:00
|
|
|
g->viewport = GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(g->scrolledwindow)));
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Attach ourselves into our parent at the right point */
|
|
|
|
nsgtk_gui_window_attach_child(bw->parent->window, g);
|
|
|
|
} else {
|
|
|
|
g->scrolledwindow = 0;
|
|
|
|
g->viewport = GTK_VIEWPORT(gtk_viewport_new(NULL, NULL)); /* Need to attach adjustments */
|
|
|
|
gtk_container_add(GTK_CONTAINER(g->viewport), GTK_WIDGET(g->fixed));
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Attach our viewport into the scaffold */
|
|
|
|
nsgtk_attach_toplevel_viewport(g->scaffold, g->viewport);
|
|
|
|
}
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(g->viewport), 0);
|
|
|
|
gtk_viewport_set_shadow_type(g->viewport, GTK_SHADOW_NONE);
|
|
|
|
if (g->scrolledwindow)
|
|
|
|
gtk_widget_show(GTK_WIDGET(g->scrolledwindow));
|
|
|
|
/* And enable visibility from our viewport down */
|
|
|
|
gtk_widget_show(GTK_WIDGET(g->viewport));
|
|
|
|
gtk_widget_show(GTK_WIDGET(g->fixed));
|
|
|
|
gtk_widget_show(GTK_WIDGET(g->drawing_area));
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
switch(bw->scrolling) {
|
|
|
|
case SCROLLING_NO:
|
|
|
|
scrollpolicy = GTK_POLICY_NEVER;
|
|
|
|
break;
|
|
|
|
case SCROLLING_YES:
|
|
|
|
scrollpolicy = GTK_POLICY_ALWAYS;
|
|
|
|
break;
|
|
|
|
case SCROLLING_AUTO:
|
2007-02-10 05:27:06 +03:00
|
|
|
default:
|
2006-11-27 20:13:24 +03:00
|
|
|
scrollpolicy = GTK_POLICY_AUTOMATIC;
|
|
|
|
break;
|
|
|
|
};
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
switch(bw->browser_window_type) {
|
|
|
|
case BROWSER_WINDOW_FRAMESET:
|
|
|
|
if (g->scrolledwindow)
|
|
|
|
gtk_scrolled_window_set_policy(g->scrolledwindow,
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_NEVER);
|
|
|
|
break;
|
|
|
|
case BROWSER_WINDOW_FRAME:
|
|
|
|
if (g->scrolledwindow)
|
|
|
|
gtk_scrolled_window_set_policy(g->scrolledwindow,
|
|
|
|
scrollpolicy,
|
|
|
|
scrollpolicy);
|
|
|
|
break;
|
|
|
|
case BROWSER_WINDOW_NORMAL:
|
|
|
|
if (g->scrolledwindow)
|
|
|
|
gtk_scrolled_window_set_policy(g->scrolledwindow,
|
|
|
|
scrollpolicy,
|
|
|
|
scrollpolicy);
|
|
|
|
break;
|
|
|
|
case BROWSER_WINDOW_IFRAME:
|
|
|
|
if (g->scrolledwindow)
|
|
|
|
gtk_scrolled_window_set_policy(g->scrolledwindow,
|
|
|
|
scrollpolicy,
|
|
|
|
scrollpolicy);
|
|
|
|
break;
|
|
|
|
}
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* set the events we're interested in receiving from the browser's
|
|
|
|
* drawing area.
|
|
|
|
*/
|
2007-01-27 22:29:28 +03:00
|
|
|
gtk_widget_add_events(GTK_WIDGET(g->drawing_area),
|
2006-11-27 20:13:24 +03:00
|
|
|
GDK_EXPOSURE_MASK |
|
|
|
|
GDK_LEAVE_NOTIFY_MASK |
|
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_KEY_PRESS_MASK |
|
|
|
|
GDK_KEY_RELEASE_MASK);
|
|
|
|
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(g->drawing_area), GTK_CAN_FOCUS);
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* set the default background colour of the drawing area to white. */
|
|
|
|
gtk_widget_modify_bg(GTK_WIDGET(g->drawing_area), GTK_STATE_NORMAL,
|
|
|
|
&((GdkColor) { 0, 0xffff, 0xffff, 0xffff } ));
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
#define CONNECT(obj, sig, callback, ptr) \
|
|
|
|
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
|
|
|
|
CONNECT(g->drawing_area, "expose_event", nsgtk_window_expose_event, g);
|
|
|
|
CONNECT(g->drawing_area, "motion_notify_event",
|
|
|
|
nsgtk_window_motion_notify_event, g);
|
|
|
|
CONNECT(g->drawing_area, "button_press_event",
|
|
|
|
nsgtk_window_button_press_event, g);
|
|
|
|
CONNECT(g->drawing_area, "key_press_event",
|
|
|
|
nsgtk_window_keypress_event, g);
|
|
|
|
CONNECT(g->viewport, "size_allocate",
|
|
|
|
nsgtk_window_size_allocate_event, g);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
return g;
|
2006-07-14 15:52:51 +04:00
|
|
|
}
|
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
static void nsgtk_gui_window_attach_child(struct gui_window *parent,
|
|
|
|
struct gui_window *child)
|
2006-03-26 18:58:15 +04:00
|
|
|
{
|
2006-11-27 20:13:24 +03:00
|
|
|
/* Attach the child gui_window (frame) into the parent.
|
|
|
|
* It will be resized later on.
|
|
|
|
*/
|
|
|
|
GtkFixed *parent_fixed = parent->fixed;
|
|
|
|
GtkWidget *child_widget = GTK_WIDGET(child->scrolledwindow);
|
|
|
|
gtk_fixed_put(parent_fixed, child_widget, 0, 0);
|
2006-03-26 18:58:15 +04:00
|
|
|
}
|
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int y1)
|
2006-08-29 00:24:45 +04:00
|
|
|
{
|
2006-11-27 20:13:24 +03:00
|
|
|
/* g is a child frame, we need to place it relative to its parent */
|
|
|
|
GtkWidget *w = GTK_WIDGET(g->scrolledwindow);
|
|
|
|
GtkFixed *f = g->bw->parent->window->fixed;
|
|
|
|
assert(w);
|
|
|
|
assert(f);
|
|
|
|
LOG(("%s: %d,%d %dx%d", g->bw->name, x0, y0, x1-x0+2, y1-y0+2));
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-06-10 20:23:59 +04:00
|
|
|
/* if the window has not changed position or size, do not bother
|
|
|
|
* moving/resising it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
LOG((" current: %d,%d %dx%d",
|
|
|
|
w->allocation.x, w->allocation.y,
|
|
|
|
w->allocation.width, w->allocation.height));
|
|
|
|
|
|
|
|
if (w->allocation.x != x0 || w->allocation.y != y0 ||
|
|
|
|
w->allocation.width != x1 - x0 + 2 ||
|
|
|
|
w->allocation.height != y1 - y0 + 2) {
|
|
|
|
LOG((" frame has moved/resized."));
|
|
|
|
gtk_fixed_move(f, w, x0, y0);
|
|
|
|
gtk_widget_set_size_request(w, x1 - x0 + 2, y1 - y0 + 2);
|
|
|
|
}
|
2006-08-29 00:24:45 +04:00
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gboolean nsgtk_window_expose_event(GtkWidget *widget,
|
2006-11-27 20:13:24 +03:00
|
|
|
GdkEventExpose *event, gpointer data)
|
2006-03-26 18:58:15 +04:00
|
|
|
{
|
2006-03-26 21:22:29 +04:00
|
|
|
struct gui_window *g = data;
|
2007-04-30 06:31:38 +04:00
|
|
|
struct content *c;
|
2007-08-07 07:55:18 +04:00
|
|
|
float scale = g->bw->scale;
|
2007-04-30 06:31:38 +04:00
|
|
|
|
|
|
|
assert(g);
|
|
|
|
assert(g->bw);
|
|
|
|
|
|
|
|
struct gui_window *z;
|
|
|
|
for (z = window_list; z && z != g; z = z->next)
|
|
|
|
continue;
|
|
|
|
assert(z);
|
2007-05-06 21:50:28 +04:00
|
|
|
assert(GTK_WIDGET(g->drawing_area) == widget);
|
2007-04-30 06:31:38 +04:00
|
|
|
|
|
|
|
c = g->bw->current_content;
|
2006-08-16 01:29:20 +04:00
|
|
|
if (c == NULL)
|
|
|
|
return FALSE;
|
2007-08-07 07:55:18 +04:00
|
|
|
|
|
|
|
/* HTML rendering handles scale itself */
|
|
|
|
if (c->type == CONTENT_HTML)
|
|
|
|
scale = 1;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
current_widget = widget;
|
2006-08-16 01:29:20 +04:00
|
|
|
current_drawable = widget->window;
|
|
|
|
current_gc = gdk_gc_new(current_drawable);
|
|
|
|
#ifdef CAIRO_VERSION
|
|
|
|
current_cr = gdk_cairo_create(current_drawable);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
plot = nsgtk_plotters;
|
2007-08-07 07:55:18 +04:00
|
|
|
nsgtk_plot_set_scale(g->bw->scale);
|
2006-08-16 01:29:20 +04:00
|
|
|
content_redraw(c, 0, 0,
|
2007-08-07 07:55:18 +04:00
|
|
|
widget->allocation.width * scale,
|
|
|
|
widget->allocation.height * scale,
|
2006-08-16 01:29:20 +04:00
|
|
|
event->area.x,
|
|
|
|
event->area.y,
|
|
|
|
event->area.x + event->area.width,
|
|
|
|
event->area.y + event->area.height,
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->scale, 0xFFFFFF);
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
if (g->careth != 0)
|
2006-08-29 00:24:45 +04:00
|
|
|
nsgtk_plot_caret(g->caretx, g->carety, g->careth);
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
g_object_unref(current_gc);
|
|
|
|
#ifdef CAIRO_VERSION
|
|
|
|
cairo_destroy(current_cr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return FALSE;
|
2006-03-26 18:58:15 +04:00
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gboolean nsgtk_window_motion_notify_event(GtkWidget *widget,
|
2006-11-27 20:13:24 +03:00
|
|
|
GdkEventMotion *event, gpointer data)
|
2006-03-26 18:58:15 +04:00
|
|
|
{
|
2006-03-26 21:22:29 +04:00
|
|
|
struct gui_window *g = data;
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
browser_window_mouse_track(g->bw, 0, event->x / g->bw->scale,
|
|
|
|
event->y / g->bw->scale);
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
g->last_x = event->x;
|
|
|
|
g->last_y = event->y;
|
|
|
|
|
|
|
|
return TRUE;
|
2006-03-26 18:58:15 +04:00
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gboolean nsgtk_window_button_press_event(GtkWidget *widget,
|
2006-11-27 20:13:24 +03:00
|
|
|
GdkEventButton *event, gpointer data)
|
2006-03-26 19:07:25 +04:00
|
|
|
{
|
|
|
|
struct gui_window *g = data;
|
2006-08-16 01:29:20 +04:00
|
|
|
int button = BROWSER_MOUSE_CLICK_1;
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
if (event->button == 2) /* 2 == middle button on X */
|
|
|
|
button = BROWSER_MOUSE_CLICK_2;
|
|
|
|
|
2007-07-09 17:49:58 +04:00
|
|
|
if (event->button == 3) {
|
|
|
|
/* 3 == right button on X */
|
|
|
|
nsgtk_scaffolding_popup_menu(g->scaffold, event->button);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
browser_window_mouse_click(g->bw, button,
|
2007-08-07 07:55:18 +04:00
|
|
|
event->x / g->bw->scale,
|
|
|
|
event->y / g->bw->scale);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-08-08 00:50:39 +04:00
|
|
|
gtk_widget_grab_focus(widget);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
return TRUE;
|
2006-03-26 19:07:25 +04:00
|
|
|
}
|
2004-06-22 22:48:33 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
wchar_t gdkkey_to_nskey(GdkEventKey *key)
|
|
|
|
{
|
|
|
|
/* this function will need to become much more complex to support
|
|
|
|
* everything that the RISC OS version does. But this will do for
|
|
|
|
* now. I hope.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (key->keyval)
|
|
|
|
{
|
|
|
|
case GDK_BackSpace: return KEY_DELETE_LEFT;
|
|
|
|
case GDK_Delete: return KEY_DELETE_RIGHT;
|
|
|
|
case GDK_Linefeed: return 13;
|
|
|
|
case GDK_Return: return 10;
|
|
|
|
case GDK_Left: return KEY_LEFT;
|
|
|
|
case GDK_Right: return KEY_RIGHT;
|
|
|
|
case GDK_Up: return KEY_UP;
|
|
|
|
case GDK_Down: return KEY_DOWN;
|
|
|
|
|
|
|
|
/* Modifiers - do nothing for now */
|
|
|
|
case GDK_Shift_L:
|
|
|
|
case GDK_Shift_R:
|
|
|
|
case GDK_Control_L:
|
|
|
|
case GDK_Control_R:
|
|
|
|
case GDK_Caps_Lock:
|
|
|
|
case GDK_Shift_Lock:
|
|
|
|
case GDK_Meta_L:
|
|
|
|
case GDK_Meta_R:
|
|
|
|
case GDK_Alt_L:
|
|
|
|
case GDK_Alt_R:
|
|
|
|
case GDK_Super_L:
|
|
|
|
case GDK_Super_R:
|
|
|
|
case GDK_Hyper_L:
|
|
|
|
case GDK_Hyper_R: return 0;
|
|
|
|
|
2007-12-11 22:34:49 +03:00
|
|
|
default: return gdk_keyval_to_unicode(
|
|
|
|
key->keyval);
|
2006-11-27 20:13:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gboolean nsgtk_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
|
|
|
|
gpointer data)
|
2004-10-18 01:51:06 +04:00
|
|
|
{
|
|
|
|
struct gui_window *g = data;
|
2006-08-16 01:29:20 +04:00
|
|
|
wchar_t nskey = gdkkey_to_nskey(event);
|
|
|
|
|
2007-03-07 00:29:51 +03:00
|
|
|
if (browser_window_key_press(g->bw, nskey))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (event->state == 0) {
|
|
|
|
double value;
|
2007-08-08 00:50:39 +04:00
|
|
|
GtkAdjustment *vscroll = gtk_viewport_get_vadjustment(g->viewport);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-08-08 00:50:39 +04:00
|
|
|
GtkAdjustment *hscroll = gtk_viewport_get_hadjustment(g->viewport);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-03-07 00:29:51 +03:00
|
|
|
GtkAdjustment *scroll;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
|
|
|
const GtkAllocation *const alloc =
|
2007-03-07 00:29:51 +03:00
|
|
|
>K_WIDGET(g->viewport)->allocation;
|
|
|
|
|
|
|
|
switch (event->keyval) {
|
|
|
|
default:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case GDK_Home:
|
|
|
|
case GDK_KP_Home:
|
|
|
|
scroll = vscroll;
|
|
|
|
value = scroll->lower;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_End:
|
|
|
|
case GDK_KP_End:
|
|
|
|
scroll = vscroll;
|
|
|
|
value = scroll->upper - alloc->height;
|
|
|
|
if (value < scroll->lower)
|
|
|
|
value = scroll->lower;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Left:
|
|
|
|
case GDK_KP_Left:
|
|
|
|
scroll = hscroll;
|
2007-08-08 20:16:03 +04:00
|
|
|
value = gtk_adjustment_get_value(scroll) -
|
2007-03-07 00:29:51 +03:00
|
|
|
scroll->step_increment;
|
|
|
|
if (value < scroll->lower)
|
|
|
|
value = scroll->lower;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Up:
|
|
|
|
case GDK_KP_Up:
|
|
|
|
scroll = vscroll;
|
2007-08-08 20:16:03 +04:00
|
|
|
value = gtk_adjustment_get_value(scroll) -
|
2007-03-07 00:29:51 +03:00
|
|
|
scroll->step_increment;
|
|
|
|
if (value < scroll->lower)
|
|
|
|
value = scroll->lower;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Right:
|
|
|
|
case GDK_KP_Right:
|
|
|
|
scroll = hscroll;
|
2007-08-08 20:16:03 +04:00
|
|
|
value = gtk_adjustment_get_value(scroll) +
|
2007-03-07 00:29:51 +03:00
|
|
|
scroll->step_increment;
|
|
|
|
if (value > scroll->upper - alloc->width)
|
|
|
|
value = scroll->upper - alloc->width;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Down:
|
|
|
|
case GDK_KP_Down:
|
|
|
|
scroll = vscroll;
|
2007-08-08 20:16:03 +04:00
|
|
|
value = gtk_adjustment_get_value(scroll) +
|
2007-03-07 00:29:51 +03:00
|
|
|
scroll->step_increment;
|
|
|
|
if (value > scroll->upper - alloc->height)
|
|
|
|
value = scroll->upper - alloc->height;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Page_Up:
|
|
|
|
case GDK_KP_Page_Up:
|
|
|
|
scroll = vscroll;
|
|
|
|
value = gtk_adjustment_get_value(scroll) -
|
|
|
|
scroll->page_increment;
|
|
|
|
if (value < scroll->lower)
|
|
|
|
value = scroll->lower;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Page_Down:
|
|
|
|
case GDK_KP_Page_Down:
|
|
|
|
scroll = vscroll;
|
2007-08-08 20:16:03 +04:00
|
|
|
value = gtk_adjustment_get_value(scroll) +
|
2007-03-07 00:29:51 +03:00
|
|
|
scroll->page_increment;
|
|
|
|
if (value > scroll->upper - alloc->height)
|
|
|
|
value = scroll->upper - alloc->height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-08 20:16:03 +04:00
|
|
|
gtk_adjustment_set_value(scroll, value);
|
2007-03-07 00:29:51 +03:00
|
|
|
}
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
return TRUE;
|
2004-10-18 01:51:06 +04:00
|
|
|
}
|
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
gboolean nsgtk_window_size_allocate_event(GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation, gpointer data)
|
|
|
|
{
|
|
|
|
struct gui_window *g = data;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->reformat_pending = true;
|
|
|
|
browser_reformat_pending = true;
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
return TRUE;
|
2006-03-26 19:34:33 +04:00
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
void nsgtk_reflow_all_windows(void)
|
|
|
|
{
|
|
|
|
for (struct gui_window *g = window_list; g; g = g->next)
|
|
|
|
g->bw->reformat_pending = true;
|
2006-08-16 01:29:20 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
browser_reformat_pending = true;
|
|
|
|
}
|
2006-08-16 01:29:20 +04:00
|
|
|
|
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
/**
|
|
|
|
* Process pending reformats
|
|
|
|
*/
|
2006-08-18 15:44:24 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
void nsgtk_window_process_reformats(void)
|
2006-08-16 01:29:20 +04:00
|
|
|
{
|
2007-08-07 07:55:18 +04:00
|
|
|
struct gui_window *g;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
browser_reformat_pending = false;
|
|
|
|
for (g = window_list; g; g = g->next) {
|
|
|
|
GtkWidget *widget = GTK_WIDGET(g->viewport);
|
|
|
|
if (!g->bw->reformat_pending)
|
|
|
|
continue;
|
|
|
|
g->bw->reformat_pending = false;
|
|
|
|
browser_window_reformat(g->bw,
|
|
|
|
widget->allocation.width - 2,
|
|
|
|
widget->allocation.height);
|
2006-11-05 02:38:18 +03:00
|
|
|
}
|
2004-07-22 16:03:37 +04:00
|
|
|
}
|
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
|
2007-06-20 23:43:09 +04:00
|
|
|
void nsgtk_window_destroy_browser(struct gui_window *g)
|
|
|
|
{
|
|
|
|
browser_window_destroy(g->bw);
|
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
void gui_window_destroy(struct gui_window *g)
|
|
|
|
{
|
2006-08-18 00:03:28 +04:00
|
|
|
if (g->prev)
|
|
|
|
g->prev->next = g->next;
|
|
|
|
else
|
|
|
|
window_list = g->next;
|
|
|
|
|
|
|
|
if (g->next)
|
|
|
|
g->next->prev = g->prev;
|
2007-08-08 20:16:03 +04:00
|
|
|
|
|
|
|
|
2007-06-10 18:40:05 +04:00
|
|
|
LOG(("Destroying gui_window %p", g));
|
|
|
|
assert(g != NULL);
|
|
|
|
assert(g->bw != NULL);
|
|
|
|
LOG((" Scaffolding: %p", g->scaffold));
|
|
|
|
LOG((" Window name: %s", g->bw->name));
|
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
/* If we're a top-level gui_window, destroy our scaffold */
|
2007-06-10 18:59:47 +04:00
|
|
|
if (g->scrolledwindow == NULL) {
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(g->viewport));
|
2006-11-27 20:13:24 +03:00
|
|
|
nsgtk_scaffolding_destroy(g->scaffold);
|
2007-06-10 18:59:47 +04:00
|
|
|
} else {
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(g->scrolledwindow));
|
|
|
|
}
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-08-18 00:03:28 +04:00
|
|
|
free(g);
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2004-07-22 16:03:37 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
void nsgtk_redraw_caret(struct gui_window *g)
|
2004-07-22 16:03:37 +04:00
|
|
|
{
|
2006-11-27 20:13:24 +03:00
|
|
|
if (g->careth == 0)
|
|
|
|
return;
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-11-27 20:13:24 +03:00
|
|
|
gui_window_redraw(g, g->caretx, g->carety,
|
|
|
|
g->caretx, g->carety + g->careth);
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2004-07-22 16:03:37 +04:00
|
|
|
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-08-16 01:29:20 +04:00
|
|
|
gtk_widget_queue_draw_area(GTK_WIDGET(g->drawing_area),
|
|
|
|
x0, y0, x1-x0+1, y1-y0+1);
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
void gui_window_redraw_window(struct gui_window *g)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-08-16 01:29:20 +04:00
|
|
|
gtk_widget_queue_draw(GTK_WIDGET(g->drawing_area));
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2004-07-22 16:03:37 +04:00
|
|
|
void gui_window_update_box(struct gui_window *g,
|
2006-08-16 01:29:20 +04:00
|
|
|
const union content_msg_data *data)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-03-10 04:42:53 +03:00
|
|
|
struct content *c = g->bw->current_content;
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
if (c == NULL)
|
|
|
|
return;
|
2006-03-10 04:42:53 +03:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gtk_widget_queue_draw_area(GTK_WIDGET(g->drawing_area),
|
2006-11-27 20:13:24 +03:00
|
|
|
data->redraw.x, data->redraw.y,
|
|
|
|
data->redraw.width, data->redraw.height);
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2005-04-15 09:52:17 +04:00
|
|
|
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
|
|
|
|
{
|
2007-06-15 12:14:55 +04:00
|
|
|
GtkAdjustment *vadj = gtk_viewport_get_vadjustment(g->viewport);
|
|
|
|
GtkAdjustment *hadj = gtk_viewport_get_hadjustment(g->viewport);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-06-15 12:14:55 +04:00
|
|
|
assert(vadj);
|
|
|
|
assert(hadj);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-06-15 12:14:55 +04:00
|
|
|
*sy = (int)(gtk_adjustment_get_value(vadj));
|
|
|
|
*sx = (int)(gtk_adjustment_get_value(hadj));
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2007-06-15 12:14:55 +04:00
|
|
|
return true;
|
2005-04-15 09:52:17 +04:00
|
|
|
}
|
|
|
|
|
2004-07-22 16:03:37 +04:00
|
|
|
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2007-06-15 12:14:55 +04:00
|
|
|
GtkAdjustment *vadj = gtk_viewport_get_vadjustment(g->viewport);
|
|
|
|
GtkAdjustment *hadj = gtk_viewport_get_hadjustment(g->viewport);
|
2007-08-22 23:43:50 +04:00
|
|
|
gdouble vlower, vpage, vupper, hlower, hpage, hupper, x = (double)sx, y = (double)sy;
|
|
|
|
|
2007-06-15 12:14:55 +04:00
|
|
|
assert(vadj);
|
|
|
|
assert(hadj);
|
2007-08-22 23:43:50 +04:00
|
|
|
|
|
|
|
g_object_get(vadj, "page-size", &vpage, "lower", &vlower, "upper", &vupper, NULL);
|
|
|
|
g_object_get(hadj, "page-size", &hpage, "lower", &hlower, "upper", &hupper, NULL);
|
|
|
|
|
2007-08-22 23:46:33 +04:00
|
|
|
if (x < hlower)
|
|
|
|
x = hlower;
|
|
|
|
if (x > (hupper - hpage))
|
|
|
|
x = hupper - hpage;
|
|
|
|
if (y < vlower)
|
|
|
|
y = vlower;
|
|
|
|
if (y > (vupper - vpage))
|
|
|
|
y = vupper - vpage;
|
2007-08-22 23:43:50 +04:00
|
|
|
|
|
|
|
gtk_adjustment_set_value(vadj, y);
|
|
|
|
gtk_adjustment_set_value(hadj, x);
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2004-06-22 22:48:33 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the scale setting of a window
|
|
|
|
*
|
|
|
|
* \param g gui window
|
|
|
|
* \param scale scale value (1.0 == normal scale)
|
|
|
|
*/
|
2006-09-08 21:11:01 +04:00
|
|
|
|
|
|
|
void gui_window_set_scale(struct gui_window *g, float scale)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
|
2006-09-06 15:29:14 +04:00
|
|
|
void gui_window_update_extent(struct gui_window *g)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-09-06 15:29:14 +04:00
|
|
|
if (!g->bw->current_content)
|
|
|
|
return;
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gtk_widget_set_size_request(GTK_WIDGET(g->drawing_area),
|
2007-08-07 07:55:18 +04:00
|
|
|
g->bw->current_content->width * g->bw->scale,
|
|
|
|
g->bw->current_content->height * g->bw->scale);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gtk_widget_set_size_request(GTK_WIDGET(g->viewport), 0, 0);
|
2007-08-08 20:16:03 +04:00
|
|
|
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2007-09-29 03:54:30 +04:00
|
|
|
static GdkCursor *nsgtk_create_menu_cursor(void)
|
|
|
|
{
|
|
|
|
static char menu_cursor_bits[] = {
|
|
|
|
0x00, 0x00, 0x80, 0x7F, 0x88, 0x40, 0x9E, 0x5E, 0x88, 0x40, 0x80, 0x56,
|
|
|
|
0x80, 0x40, 0x80, 0x5A, 0x80, 0x40, 0x80, 0x5E, 0x80, 0x40, 0x80, 0x56,
|
|
|
|
0x80, 0x40, 0x80, 0x7F, 0x00, 0x00, 0x00, 0x00, };
|
|
|
|
|
|
|
|
static char menu_cursor_mask_bits[] = {
|
|
|
|
0xC0, 0xFF, 0xC8, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0xC8, 0xFF,
|
|
|
|
0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF,
|
|
|
|
0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0x00, 0x00, };
|
|
|
|
|
|
|
|
static GdkCursor *r;
|
|
|
|
static GdkColor fg = { 0, 0, 0, 0 };
|
|
|
|
static GdkColor bg = { 0, 65535, 65535, 65535 };
|
|
|
|
|
|
|
|
GdkPixmap *source, *mask;
|
|
|
|
|
|
|
|
if (r != NULL)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
source = gdk_bitmap_create_from_data(NULL, menu_cursor_bits,
|
|
|
|
16, 16);
|
|
|
|
mask = gdk_bitmap_create_from_data (NULL, menu_cursor_mask_bits,
|
|
|
|
16, 16);
|
|
|
|
|
|
|
|
r = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 8, 8);
|
|
|
|
gdk_pixmap_unref(source);
|
|
|
|
gdk_pixmap_unref(mask);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-03-10 12:09:03 +03:00
|
|
|
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-08-16 01:29:20 +04:00
|
|
|
GdkCursor *cursor = NULL;
|
|
|
|
GdkCursorType cursortype;
|
|
|
|
bool nullcursor = false;
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
if (g->current_pointer == shape)
|
|
|
|
return;
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-03-10 12:46:26 +03:00
|
|
|
g->current_pointer = shape;
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-03-10 12:46:26 +03:00
|
|
|
switch (shape) {
|
2006-08-16 01:29:20 +04:00
|
|
|
case GUI_POINTER_POINT:
|
2007-10-05 01:19:39 +04:00
|
|
|
cursortype = GDK_HAND2;
|
2006-08-16 01:29:20 +04:00
|
|
|
break;
|
|
|
|
case GUI_POINTER_CARET:
|
|
|
|
cursortype = GDK_XTERM;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_UP:
|
|
|
|
cursortype = GDK_TOP_SIDE;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_DOWN:
|
|
|
|
cursortype = GDK_BOTTOM_SIDE;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_LEFT:
|
|
|
|
cursortype = GDK_LEFT_SIDE;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_RIGHT:
|
|
|
|
cursortype = GDK_RIGHT_SIDE;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_LD:
|
|
|
|
cursortype = GDK_BOTTOM_LEFT_CORNER;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_RD:
|
|
|
|
cursortype = GDK_BOTTOM_RIGHT_CORNER;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_LU:
|
|
|
|
cursortype = GDK_TOP_LEFT_CORNER;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_RU:
|
|
|
|
cursortype = GDK_TOP_RIGHT_CORNER;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_CROSS:
|
|
|
|
cursortype = GDK_CROSS;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_MOVE:
|
|
|
|
cursortype = GDK_FLEUR;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_WAIT:
|
|
|
|
cursortype = GDK_WATCH;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_HELP:
|
|
|
|
cursortype = GDK_QUESTION_ARROW;
|
|
|
|
break;
|
|
|
|
case GUI_POINTER_MENU:
|
2007-09-29 03:54:30 +04:00
|
|
|
cursor = nsgtk_create_menu_cursor();
|
|
|
|
nullcursor = true;
|
2006-08-16 01:29:20 +04:00
|
|
|
break;
|
|
|
|
case GUI_POINTER_PROGRESS:
|
|
|
|
/* In reality, this needs to be the funky left_ptr_watch
|
|
|
|
* which we can't do easily yet.
|
|
|
|
*/
|
|
|
|
cursortype = GDK_WATCH;
|
|
|
|
break;
|
|
|
|
/* The following we're not sure about */
|
|
|
|
case GUI_POINTER_NO_DROP:
|
|
|
|
case GUI_POINTER_NOT_ALLOWED:
|
|
|
|
case GUI_POINTER_DEFAULT:
|
|
|
|
default:
|
|
|
|
nullcursor = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nullcursor)
|
|
|
|
cursor = gdk_cursor_new_for_display(
|
|
|
|
gtk_widget_get_display(
|
2006-09-06 15:29:14 +04:00
|
|
|
GTK_WIDGET(g->drawing_area)),
|
2006-08-16 01:29:20 +04:00
|
|
|
cursortype);
|
|
|
|
gdk_window_set_cursor(GTK_WIDGET(g->drawing_area)->window, cursor);
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-03-10 12:46:26 +03:00
|
|
|
if (!nullcursor)
|
2006-08-16 01:29:20 +04:00
|
|
|
gdk_cursor_unref(cursor);
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2006-03-10 12:09:03 +03:00
|
|
|
void gui_window_hide_pointer(struct gui_window *g)
|
2005-07-21 03:27:28 +04:00
|
|
|
{
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2005-07-21 03:27:28 +04:00
|
|
|
|
2004-07-22 16:03:37 +04:00
|
|
|
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-08-16 01:29:20 +04:00
|
|
|
nsgtk_redraw_caret(g);
|
2006-04-20 20:26:26 +04:00
|
|
|
|
|
|
|
g->caretx = x;
|
|
|
|
g->carety = y + 1;
|
2008-03-11 03:26:47 +03:00
|
|
|
g->careth = height - 2;
|
2006-04-20 20:26:26 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
nsgtk_redraw_caret(g);
|
2006-04-20 20:26:26 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gtk_widget_grab_focus(GTK_WIDGET(g->drawing_area));
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2004-07-22 16:03:37 +04:00
|
|
|
void gui_window_remove_caret(struct gui_window *g)
|
2004-06-22 22:48:33 +04:00
|
|
|
{
|
2006-08-29 00:31:21 +04:00
|
|
|
int oh = g->careth;
|
2006-09-06 15:29:14 +04:00
|
|
|
|
2006-08-29 00:31:21 +04:00
|
|
|
if (oh == 0)
|
2006-08-16 01:29:20 +04:00
|
|
|
return;
|
2006-04-20 20:26:26 +04:00
|
|
|
|
2006-08-29 00:31:21 +04:00
|
|
|
g->careth = 0;
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
gui_window_redraw(g, g->caretx, g->carety,
|
2006-11-27 20:13:24 +03:00
|
|
|
g->caretx, g->carety + oh);
|
2004-06-22 22:48:33 +04:00
|
|
|
}
|
|
|
|
|
2004-07-22 16:03:37 +04:00
|
|
|
void gui_window_new_content(struct gui_window *g)
|
2004-07-21 18:19:21 +04:00
|
|
|
{
|
2005-04-15 09:52:17 +04:00
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2005-04-15 09:52:17 +04:00
|
|
|
|
|
|
|
bool gui_window_scroll_start(struct gui_window *g)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-07-21 03:27:28 +04:00
|
|
|
bool gui_window_box_scroll_start(struct gui_window *g,
|
2006-08-16 01:29:20 +04:00
|
|
|
int x0, int y0, int x1, int y1)
|
2005-07-21 03:27:28 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2005-04-15 09:52:17 +04:00
|
|
|
|
2005-04-18 16:07:27 +04:00
|
|
|
void gui_drag_save_object(gui_save_type type, struct content *c,
|
2006-11-27 20:13:24 +03:00
|
|
|
struct gui_window *g)
|
2005-04-15 09:52:17 +04:00
|
|
|
{
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2005-04-15 09:52:17 +04:00
|
|
|
|
2005-04-18 16:07:27 +04:00
|
|
|
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
|
2005-04-15 09:52:17 +04:00
|
|
|
{
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2005-04-15 09:52:17 +04:00
|
|
|
|
|
|
|
void gui_start_selection(struct gui_window *g)
|
|
|
|
{
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2005-04-15 09:52:17 +04:00
|
|
|
|
2005-04-26 00:58:22 +04:00
|
|
|
void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
|
2005-04-20 16:24:41 +04:00
|
|
|
{
|
|
|
|
|
2006-08-16 01:29:20 +04:00
|
|
|
}
|
2005-04-20 16:24:41 +04:00
|
|
|
|
2005-07-21 03:27:28 +04:00
|
|
|
bool gui_empty_clipboard(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
|
|
|
|
{
|
2006-08-16 01:29:20 +04:00
|
|
|
return true;
|
2005-07-21 03:27:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_commit_clipboard(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-15 09:52:17 +04:00
|
|
|
bool gui_copy_to_clipboard(struct selection *s)
|
|
|
|
{
|
2005-07-21 03:27:28 +04:00
|
|
|
return true;
|
2005-04-15 09:52:17 +04:00
|
|
|
}
|
|
|
|
|
2006-04-20 20:26:26 +04:00
|
|
|
|
2006-09-08 00:27:59 +04:00
|
|
|
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
|
2006-11-27 20:13:24 +03:00
|
|
|
bool scaled)
|
2006-09-06 15:29:14 +04:00
|
|
|
{
|
2007-06-18 22:48:37 +04:00
|
|
|
*width = GTK_WIDGET(g->viewport)->allocation.width;
|
|
|
|
*height = GTK_WIDGET(g->viewport)->allocation.height;
|
2006-09-08 00:27:59 +04:00
|
|
|
|
|
|
|
if (scaled) {
|
2007-08-07 07:55:18 +04:00
|
|
|
*width /= g->bw->scale;
|
|
|
|
*height /= g->bw->scale;
|
2006-09-08 00:27:59 +04:00
|
|
|
}
|
2006-09-06 15:29:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_window_frame_resize_start(struct gui_window *g)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|