summaryrefslogtreecommitdiff
path: root/render/textplain.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2010-06-04 09:35:08 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2010-06-04 09:35:08 +0000
commitb010a257712b3d104035cbfc15aba8f517ffacb5 (patch)
treeba220c9c0c2c02ea1a8441ad8ace44d4c0bc5164 /render/textplain.c
parentbc9fef0a1a7a45a640d37353f97e72006e1e09b6 (diff)
downloadnetsurf-b010a257712b3d104035cbfc15aba8f517ffacb5.tar.gz
netsurf-b010a257712b3d104035cbfc15aba8f517ffacb5.tar.bz2
+ Refactor input handling from browser window code into content
handlers. + Disentangle all box tree manipulation from browser window code and put it where it belongs. + Move other content specific and other irrelevant code from browser window handling to appropriate places. + Put mouse state enum in new mouse header, since it's not just used by browser window code, and it is used by treeview windows on the treeview branch. svn path=/trunk/netsurf/; revision=10561
Diffstat (limited to 'render/textplain.c')
-rw-r--r--render/textplain.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/render/textplain.c b/render/textplain.c
index f39a89a08..94a5cce66 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -32,6 +32,7 @@
#include "content/hlcache.h"
#include "css/css.h"
#include "css/utils.h"
+#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/options.h"
#include "desktop/plotters.h"
@@ -355,6 +356,93 @@ bool textplain_clone(const struct content *old, struct content *new_content)
/**
+ * Handle mouse tracking (including drags) in a TEXTPLAIN content window.
+ *
+ * \param c content of type textplain
+ * \param bw browser window
+ * \param mouse state of mouse buttons and modifier keys
+ * \param x coordinate of mouse
+ * \param y coordinate of mouse
+ */
+
+void textplain_mouse_track(struct content *c, struct browser_window *bw,
+ browser_mouse_state mouse, int x, int y)
+{
+ switch (bw->drag_type) {
+
+ case DRAGGING_SELECTION: {
+ hlcache_handle *h = bw->current_content;
+ int dir = -1;
+ size_t idx;
+
+ if (selection_dragging_start(bw->sel)) dir = 1;
+
+ idx = textplain_offset_from_coords(h, x, y, dir);
+ selection_track(bw->sel, mouse, idx);
+ }
+ break;
+
+ default:
+ textplain_mouse_action(c, bw, mouse, x, y);
+ break;
+ }
+}
+
+
+/**
+ * Handle mouse clicks and movements in a TEXTPLAIN content window.
+ *
+ * \param c content of type textplain
+ * \param bw browser window
+ * \param click type of mouse click
+ * \param x coordinate of mouse
+ * \param y coordinate of mouse
+ */
+
+void textplain_mouse_action(struct content *c, struct browser_window *bw,
+ browser_mouse_state mouse, int x, int y)
+{
+ hlcache_handle *h = bw->current_content;
+ gui_pointer_shape pointer = GUI_POINTER_DEFAULT;
+ const char *status = 0;
+ size_t idx;
+ int dir = 0;
+
+ bw->drag_type = DRAGGING_NONE;
+
+ if (!bw->sel) return;
+
+ idx = textplain_offset_from_coords(h, x, y, dir);
+ if (selection_click(bw->sel, mouse, idx)) {
+
+ if (selection_dragging(bw->sel)) {
+ bw->drag_type = DRAGGING_SELECTION;
+ status = messages_get("Selecting");
+ }
+ else
+ status = content_get_status_message(h);
+ }
+ else {
+ if (bw->loading_content)
+ status = content_get_status_message(
+ bw->loading_content);
+ else
+ status = content_get_status_message(h);
+
+ if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2)) {
+ browser_window_page_drag_start(bw, x, y);
+ pointer = GUI_POINTER_MOVE;
+ }
+ }
+
+ assert(status);
+
+ browser_window_set_status(bw, status);
+ browser_window_set_pointer(bw->window, pointer);
+}
+
+
+/**
* Draw a CONTENT_TEXTPLAIN using the current set of plotters (plot).
*
* \param c content of type CONTENT_TEXTPLAIN