NetSurf
|
Amiga core window interface. More...
#include "amiga/os3support.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
#include "netsurf/plot_style.h"
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/layout.h>
#include <proto/utility.h>
#include <classes/window.h>
#include <gadgets/layout.h>
#include <gadgets/scroller.h>
#include <gadgets/space.h>
#include <intuition/icclass.h>
#include <reaction/reaction_macros.h>
#include "amiga/corewindow.h"
#include "amiga/drag.h"
#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/object.h"
#include "amiga/schedule.h"
#include "amiga/utf8.h"
Go to the source code of this file.
Functions | |
static void | ami_cw_scroller_top (struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y) |
static void | ami_cw_window_size (struct ami_corewindow *ami_cw, int *width, int *height) |
static void | ami_cw_coord_amiga_to_ns (struct ami_corewindow *ami_cw, int *restrict x, int *restrict y) |
Convert co-ordinates relative to space.gadget into document co-ordinates. More... | |
static bool | ami_cw_mouse_moved (struct ami_corewindow *ami_cw, int x, int y, bool click) |
check if mouse has moved since position was stored More... | |
static bool | ami_cw_mouse_pos (struct ami_corewindow *ami_cw, int *restrict x, int *restrict y) |
static void | ami_cw_key (struct ami_corewindow *ami_cw, int nskey) |
static void | ami_cw_redraw_rect (struct ami_corewindow *ami_cw, struct rect *r) |
Redraw functions. More... | |
static void | ami_cw_redraw_queue (struct ami_corewindow *ami_cw, bool draw) |
Draw the deferred rectangles. More... | |
static void | ami_cw_redraw_cb (void *p) |
static void | ami_cw_redraw (struct ami_corewindow *ami_cw, const struct rect *restrict r) |
Queue a redraw of a rectangle. More... | |
static void | ami_cw_simplerefresh (struct ami_corewindow *ami_cw) |
static void | ami_cw_toggle_scrollbar (struct ami_corewindow *ami_cw, bool vert, bool visible) |
static void | ami_cw_close (void *w) |
HOOKF (void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *) | |
static void | ami_cw_drag_start (struct ami_corewindow *ami_cw, int x, int y) |
Drag start. More... | |
static void | ami_cw_drag_progress (struct ami_corewindow *ami_cw, int x, int y) |
Drag progress. More... | |
static void | ami_cw_drag_end (struct ami_corewindow *ami_cw, int x, int y) |
Drag end. More... | |
static void | ami_cw_newsize (struct ami_corewindow *ami_cw) |
User has resized window. More... | |
static BOOL | ami_cw_event (void *w) |
Main event loop for our core window. More... | |
static nserror | ami_cw_invalidate_area (struct core_window *cw, const struct rect *r) |
callback from core to request an invalidation of a amiga core window area. More... | |
static nserror | ami_cw_get_window_dimensions (const struct core_window *cw, int *width, int *height) |
static nserror | ami_cw_update_size (struct core_window *cw, int width, int height) |
static nserror | ami_cw_get_scroll (const struct core_window *cw, int *x, int *y) |
static nserror | ami_cw_set_scroll (struct core_window *cw, int x, int y) |
static nserror | ami_cw_drag_status (struct core_window *cw, core_window_drag_status ds) |
nserror | ami_corewindow_init (struct ami_corewindow *ami_cw) |
initialise elements of Amiga core window. More... | |
nserror | ami_corewindow_fini (struct ami_corewindow *ami_cw) |
finalise elements of Amiga core window. More... | |
Variables | |
static const struct ami_win_event_table | ami_cw_table |
struct core_window_table | ami_cw_cb_table |
struct core_window_table * | amiga_core_window_table = &ami_cw_cb_table |
Amiga core window interface.
Provides interface for core renderers to the Amiga Intuition drawable area.
This module is an object that must be encapsulated. Client users should embed a struct ami_corewindow at the beginning of their context for this display surface, fill in relevant data and then call ami_corewindow_init()
The Amiga core window structure requires the callback for draw, key and mouse operations.
Definition in file corewindow.c.
nserror ami_corewindow_fini | ( | struct ami_corewindow * | ami_cw | ) |
finalise elements of Amiga core window.
ami_cw | An Amiga core window structure to finialise |
Definition at line 987 of file corewindow.c.
References ami_cw_redraw_cb(), ami_gui_win_list_remove(), ami_memory_itempool_delete, ami_plot_ra_free(), ami_schedule(), ami_utf8_free(), ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, FreeObjList(), ami_corewindow::gg, GID_CW_HSCROLL, GID_CW_VSCROLL, GID_CW_WIN, ami_corewindow::in_border_scroll, NSERROR_OK, ami_corewindow::objects, ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, ami_corewindow::win, and ami_corewindow::wintitle.
Referenced by ami_cookies_destroy(), ami_history_global_destroy(), ami_history_local_destroy(), ami_hotlist_destroy(), and ami_pageinfo_destroy().
nserror ami_corewindow_init | ( | struct ami_corewindow * | ami_cw | ) |
initialise elements of Amiga core window.
As a pre-requisite the draw, key and mouse callbacks must be defined
ami_cw | An Amiga core window structure to initialise |
Definition at line 928 of file corewindow.c.
References ami_cw_table, ami_gui_win_list_add(), ami_memory_itempool_create, ami_plot_ra_alloc(), AMINS_COREWINDOW, BROWSER_MOUSE_HOVER, CORE_WINDOW_DRAG_NONE, ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, ami_corewindow::drag_status, ami_corewindow::dragging, ami_corewindow::gg, GID_CW_HSCROLL, GID_CW_VSCROLL, GID_CW_WIN, ami_corewindow::idcmp_hook, ami_corewindow::in_border_scroll, ami_corewindow::lastclick, ami_corewindow::mouse_state, NewObjList(), NSERROR_OK, ami_corewindow::objects, RefreshSetGadgetAttrs(), ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, and ami_corewindow::win.
Referenced by ami_cookies_present(), ami_history_global_present(), ami_history_local_present(), ami_hotlist_present(), and ami_pageinfo_open().
|
static |
Definition at line 488 of file corewindow.c.
References ami_corewindow::close, and ami_corewindow::w.
Referenced by ami_cw_event().
|
static |
Convert co-ordinates relative to space.gadget into document co-ordinates.
ami_cw | core window |
x | co-ordinate, will be updated to new x co-ordinate |
y | co-ordinate, will be updated to new y co-ordinate |
Definition at line 116 of file corewindow.c.
References ami_cw_scroller_top().
Referenced by ami_cw_redraw(), and ami_cw_simplerefresh().
|
static |
Drag end.
Definition at line 587 of file corewindow.c.
References ami_drag_icon_close(), ami_gui_get_screen(), ami_window_at_pointer(), AMINS_COREWINDOW, CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_NONE, CORE_WINDOW_DRAG_SELECTION, ami_corewindow::drag_end, ami_corewindow::drag_status, ami_corewindow::dragging, scrn, and ami_corewindow::win.
Referenced by ami_cw_event().
|
static |
Drag progress.
Definition at line 566 of file corewindow.c.
References ami_drag_icon_move(), CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_SELECTION, ami_corewindow::drag_status, and ami_corewindow::dragging.
Referenced by ami_cw_event().
|
static |
Drag start.
Definition at line 541 of file corewindow.c.
References ami_drag_icon_show(), CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_SELECTION, ami_corewindow::drag_status, ami_corewindow::drag_x_start, ami_corewindow::drag_y_start, ami_corewindow::dragging, and ami_corewindow::win.
Referenced by ami_cw_event().
|
static |
Definition at line 908 of file corewindow.c.
References ami_corewindow::drag_status, and NSERROR_OK.
|
static |
Main event loop for our core window.
Definition at line 642 of file corewindow.c.
References ami_cw_close(), ami_cw_drag_end(), ami_cw_drag_progress(), ami_cw_drag_start(), ami_cw_key(), ami_cw_mouse_moved(), ami_cw_mouse_pos(), ami_cw_newsize(), ami_gui_get_quals(), ami_key_to_nskey(), BROWSER_MOUSE_CLICK_1, BROWSER_MOUSE_CLICK_2, BROWSER_MOUSE_DOUBLE_CLICK, BROWSER_MOUSE_DRAG_1, BROWSER_MOUSE_DRAG_2, BROWSER_MOUSE_DRAG_ON, BROWSER_MOUSE_HOLDING_1, BROWSER_MOUSE_HOLDING_2, BROWSER_MOUSE_HOVER, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, ami_corewindow::close_window, ami_corewindow::drag_x_start, ami_corewindow::drag_y_start, ami_corewindow::event, GID_CW_WIN, ami_corewindow::lastclick, ami_corewindow::mouse, ami_corewindow::mouse_state, ami_corewindow::mouse_x_click, ami_corewindow::mouse_y_click, ami_corewindow::objects, result, and ami_corewindow::w.
|
static |
Definition at line 871 of file corewindow.c.
References ami_cw_scroller_top(), and NSERROR_OK.
|
static |
Definition at line 829 of file corewindow.c.
References ami_cw_window_size(), height, NSERROR_OK, and width.
callback from core to request an invalidation of a amiga core window area.
The specified area of the window should now be considered out of date. If the area is NULL the entire window must be invalidated.
[in] | cw | The core window to invalidate. |
[in] | r | area to redraw or NULL for the entire window area. |
Definition at line 818 of file corewindow.c.
References ami_cw_redraw(), and NSERROR_OK.
|
static |
Definition at line 190 of file corewindow.c.
References ami_corewindow::key, NS_KEY_CLEAR_SELECTION, and NS_KEY_COPY_SELECTION.
Referenced by ami_cw_event().
|
static |
check if mouse has moved since position was stored
ami_cw | corewindow |
x | current x position |
y | current y position |
click | true to check since last click, false since last drag (press) |
Definition at line 136 of file corewindow.c.
References ami_corewindow::drag_x_start, ami_corewindow::drag_y_start, ami_corewindow::mouse_x_click, and ami_corewindow::mouse_y_click.
Referenced by ami_cw_event().
|
static |
Definition at line 157 of file corewindow.c.
References ami_cw_scroller_top(), ami_gui_free_space_box(), ami_gui_get_space_box(), amiga_warn_user(), GID_CW_DRAW, NSERROR_OK, ami_corewindow::objects, and ami_corewindow::win.
Referenced by ami_cw_event().
|
static |
User has resized window.
Definition at line 616 of file corewindow.c.
References ami_cw_redraw(), ami_cw_window_size(), GID_CW_HSCROLL, GID_CW_VSCROLL, ami_corewindow::objects, RefreshSetGadgetAttrs(), and ami_corewindow::win.
Referenced by ami_cw_event().
|
static |
Queue a redraw of a rectangle.
ami_cw | the core window to redraw |
r | the rectangle (in doc coords) to redraw, or NULL for full window |
Definition at line 352 of file corewindow.c.
References AddObject(), ami_cw_coord_amiga_to_ns(), ami_cw_redraw_cb(), ami_gui_free_space_box(), ami_gui_get_space_box(), ami_gui_window_update_box_deferred_check(), ami_memory_itempool_alloc, ami_schedule(), amiga_warn_user(), AMINS_RECT, ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, GID_CW_DRAW, NSERROR_OK, NSLOG, ami_corewindow::objects, nsObject::objstruct, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by ami_cw_invalidate_area(), ami_cw_newsize(), ami_cw_set_scroll(), ami_cw_simplerefresh(), ami_cw_toggle_scrollbar(), and HOOKF().
|
static |
Definition at line 337 of file corewindow.c.
References ami_cw_redraw_queue().
Referenced by ami_corewindow_fini(), and ami_cw_redraw().
|
static |
Draw the deferred rectangles.
ami_cw | An Amiga core window structure to queue redraw |
draw | set to false to just delete the queue |
Definition at line 311 of file corewindow.c.
References ami_cw_redraw_rect(), ami_memory_itempool_free, ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, DelObjectNoFree(), GetHead(), GetSucc(), IsMinListEmpty, NSLOG, and nsObject::objstruct.
Referenced by ami_cw_redraw_cb().
|
static |
Redraw functions.
This is slightly over-engineered as it was taken from the main browser/old tree redraws and supports deferred drawing of rectangles and tiling Redraw an area of a core window
ami_cw | An Amiga core window structure |
r | rect (in document co-ordinates) |
Definition at line 221 of file corewindow.c.
References ami_clearclipreg(), ami_cw_scroller_top(), ami_gui_free_space_box(), ami_gui_get_space_box(), ami_plot_ra_get_bitmap(), ami_plot_ra_get_size(), amiga_warn_user(), amiplot, ami_corewindow::draw, ami_corewindow::gg, GID_CW_DRAW, height, redraw_context::interactive, NSERROR_OK, ami_corewindow::objects, width, ami_corewindow::win, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by ami_cw_redraw_queue().
|
static |
Definition at line 71 of file corewindow.c.
References GID_CW_HSCROLL, GID_CW_VSCROLL, ami_corewindow::objects, ami_corewindow::scroll_x_visible, and ami_corewindow::scroll_y_visible.
Referenced by ami_cw_coord_amiga_to_ns(), ami_cw_get_scroll(), ami_cw_mouse_pos(), and ami_cw_redraw_rect().
|
static |
Definition at line 885 of file corewindow.c.
References ami_cw_redraw(), GID_CW_HSCROLL, GID_CW_VSCROLL, NSERROR_OK, ami_corewindow::objects, RefreshSetGadgetAttrs(), ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, and ami_corewindow::win.
|
static |
Definition at line 389 of file corewindow.c.
References ami_cw_coord_amiga_to_ns(), ami_cw_redraw(), ami_corewindow::win, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by HOOKF().
|
static |
Definition at line 425 of file corewindow.c.
References ami_cw_redraw(), GID_CW_HSCROLL, GID_CW_HSCROLLLAYOUT, GID_CW_VSCROLL, GID_CW_VSCROLLLAYOUT, GID_CW_WIN, IDoMethod, ami_corewindow::in_border_scroll, ami_corewindow::objects, ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, and ami_corewindow::win.
Referenced by ami_cw_update_size().
|
static |
Definition at line 840 of file corewindow.c.
References ami_cw_toggle_scrollbar(), ami_cw_window_size(), GID_CW_HSCROLL, GID_CW_VSCROLL, height, NSERROR_OK, ami_corewindow::objects, RefreshSetGadgetAttrs(), width, and ami_corewindow::win.
|
static |
Definition at line 91 of file corewindow.c.
References ami_gui_free_space_box(), ami_gui_get_space_box(), amiga_warn_user(), GID_CW_DRAW, height, NSERROR_OK, ami_corewindow::objects, and width.
Referenced by ami_cw_get_window_dimensions(), ami_cw_newsize(), and ami_cw_update_size().
HOOKF | ( | void | , |
ami_cw_idcmp_hook | , | ||
Object * | , | ||
object | , | ||
struct IntuiMessage * | |||
) |
Definition at line 495 of file corewindow.c.
References ami_cw_redraw(), ami_cw_simplerefresh(), GID_CW_HSCROLL, GID_CW_VSCROLL, IDCMP_EXTENDEDMOUSE, and NSLOG.
struct core_window_table ami_cw_cb_table |
Definition at line 916 of file corewindow.c.
|
static |
Definition at line 800 of file corewindow.c.
Referenced by ami_corewindow_init().
struct core_window_table* amiga_core_window_table = &ami_cw_cb_table |
Definition at line 925 of file corewindow.c.
Referenced by main().