49#include <proto/exec.h>
50#include <proto/graphics.h>
51#include <proto/intuition.h>
52#include <proto/layout.h>
53#include <proto/utility.h>
55#include <classes/window.h>
56#include <gadgets/layout.h>
57#include <gadgets/scroller.h>
58#include <gadgets/space.h>
59#include <intuition/icclass.h>
60#include <reaction/reaction_macros.h>
100 *
width = bbox->Width;
148 if(abs(x - mx) > 5)
return true;
149 if(abs(y - my) > 5)
return true;
163 xm = ami_cw->
win->MouseX;
164 ym = ami_cw->
win->MouseY;
174 if((xm < 0) || (ym < 0) || (xm > bbox->Width) || (ym > bbox->Height))
192 ami_cw->
key(ami_cw, nskey);
225 struct rect draw_rect;
228 int tile_x, tile_y, tile_w, tile_h;
236 .background_images =
true,
248 if(x - (LONG)pos_x +
width > bbox->Width)
width = bbox->Width - (x - pos_x);
249 if(y - (LONG)pos_y +
height > bbox->Height)
height = bbox->Height - (y - pos_y);
251 if(x < (LONG)pos_x) {
256 if(y < (LONG)pos_y) {
263 for(tile_y = y; tile_y < (y +
height); tile_y += tile_size_y) {
264 tile_h = tile_size_y;
265 if(((y +
height) - tile_y) < tile_size_y)
266 tile_h = (y +
height) - tile_y;
268 for(tile_x = x; tile_x < (x +
width); tile_x += tile_size_x) {
269 tile_w = tile_size_x;
270 if(((x +
width) - tile_x) < tile_size_x)
271 tile_w = (x +
width) - tile_x;
273 draw_rect.
x0 = tile_x;
274 draw_rect.
y0 = tile_y;
275 draw_rect.
x1 = tile_x + tile_w;
276 draw_rect.
y1 = tile_y + tile_h;
278 ami_cw->
draw(ami_cw, -tile_x, -tile_y, &draw_rect, &ctx);
281 BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
285 BLITA_DestType, BLITT_RASTPORT,
286 BLITA_Dest, ami_cw->
win->RPort,
287 BLITA_DestX, bbox->Left + tile_x - pos_x,
288 BLITA_DestY, bbox->Top + tile_y - pos_y,
290 BLITA_Height, tile_h,
294 ami_cw->
win->RPort, bbox->Left + tile_x - pos_x, bbox->Top + tile_y - pos_y,
295 tile_w, tile_h, 0xC0);
320 NSLOG(netsurf, INFO,
"Ignoring deferred box redraw queue");
333 }
while((node = nnode));
355 struct rect *restrict deferred_rect;
356 struct rect new_rect;
368 new_rect.
x1 = new_rect.
x0 + bbox->Width;
369 new_rect.
y1 = new_rect.
y0 + bbox->Height;
379 CopyMem(r, deferred_rect,
sizeof(
struct rect));
384 "Ignoring duplicate or subset of queued box redraw");
392 struct RegionRectangle *regrect;
394 BeginRefresh(ami_cw->
win);
396 r.
x0 = ami_cw->
win->RPort->Layer->DamageList->bounds.MinX;
397 r.
x1 = ami_cw->
win->RPort->Layer->DamageList->bounds.MaxX;
398 r.
y0 = ami_cw->
win->RPort->Layer->DamageList->bounds.MinY;
399 r.
y1 = ami_cw->
win->RPort->Layer->DamageList->bounds.MaxY;
404 regrect = ami_cw->
win->RPort->Layer->DamageList->RegionRectangle;
409 r.
x0 = regrect->bounds.MinX;
410 r.
x1 = regrect->bounds.MaxX;
411 r.
y0 = regrect->bounds.MinY;
412 r.
y1 = regrect->bounds.MaxY;
416 regrect = regrect->Next;
421 EndRefresh(ami_cw->
win, TRUE);
437 tag = WINDOW_VertProp;
446 tag = WINDOW_HorizProp;
451 if(visible ==
true) {
458 IDoMethod(layout, LM_ADDCHILD, ami_cw->
win, scroller, NULL);
460 SetAttrs(layout, LAYOUT_AddChild, scroller, TAG_DONE);
470 IDoMethod(layout, LM_REMOVECHILD, ami_cw->
win, scroller);
472 SetAttrs(layout, LAYOUT_RemoveChild, scroller, TAG_DONE);
480 ami_cw->
win, NULL, TRUE);
492 ami_cw->
close(ami_cw);
495HOOKF(
void, ami_cw_idcmp_hook, Object *,
object,
struct IntuiMessage *)
498 struct IntuiWheelData *wheel;
499 ULONG gid = GetTagData( GA_ID, 0, msg->IAddress );
503 case IDCMP_IDCMPUPDATE:
514 if(msg->Code == IMSGCODE_INTUIWHEELDATA)
516 wheel = (
struct IntuiWheelData *)msg->IAddress;
523 case IDCMP_SIZEVERIFY:
526 case IDCMP_REFRESHWINDOW:
532 "IDCMP hook unhandled event: %ld", msg->Class);
543 if(ami_cw->
dragging ==
true)
return;
568 if(ami_cw->
dragging ==
false)
return;
589 if(ami_cw->
dragging ==
false)
return;
623 SCROLLER_Visible, win_w,
629 SCROLLER_Visible, win_h,
649 struct InputEvent *ie;
652 struct timeval curtime;
661 switch(
result & WMHI_CLASSMASK) {
689 case WMHI_MOUSEBUTTONS:
707 CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
715 curtime.tv_sec, curtime.tv_usec)))
726 ami_cw->
lastclick.tv_sec = curtime.tv_sec;
727 ami_cw->
lastclick.tv_usec = curtime.tv_usec;
770 storage =
result & WMHI_GADGETMASK;
782 case WMHI_CLOSEWINDOW:
789 if(ami_cw->
event != NULL)
852 SCROLLER_Total, (ULONG)
width,
853 SCROLLER_Visible, win_w,
863 SCROLLER_Visible, win_h,
874 ULONG win_x0, win_y0;
952 ami_cw->
idcmp_hook.h_Entry = (
void *)ami_cw_idcmp_hook;
965 ICA_TARGET, ICTARGET_IDCMP,
977 ICA_TARGET, ICTARGET_IDCMP,
static nserror ami_cw_update_size(struct core_window *cw, int width, int height)
static void ami_cw_drag_start(struct ami_corewindow *ami_cw, int x, int y)
Drag start.
static void ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
Redraw functions.
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.
struct core_window_table ami_cw_cb_table
nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
finalise elements of Amiga core window.
static void ami_cw_drag_progress(struct ami_corewindow *ami_cw, int x, int y)
Drag progress.
static nserror ami_cw_get_scroll(const struct core_window *cw, int *x, int *y)
static void ami_cw_scroller_top(struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y)
static BOOL ami_cw_event(void *w)
Main event loop for our core window.
nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
initialise elements of Amiga core window.
static void ami_cw_drag_end(struct ami_corewindow *ami_cw, int x, int y)
Drag end.
static void ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
static nserror ami_cw_get_window_dimensions(const struct core_window *cw, int *width, int *height)
static bool ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
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
static void ami_cw_close(void *w)
static void ami_cw_simplerefresh(struct ami_corewindow *ami_cw)
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.
static nserror ami_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
static nserror ami_cw_set_scroll(struct core_window *cw, int x, int y)
static void ami_cw_newsize(struct ami_corewindow *ami_cw)
User has resized window.
static void ami_cw_window_size(struct ami_corewindow *ami_cw, int *width, int *height)
struct core_window_table * amiga_core_window_table
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.
static void ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
static void ami_cw_redraw_queue(struct ami_corewindow *ami_cw, bool draw)
Draw the deferred rectangles.
static const struct ami_win_event_table ami_cw_table
bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, const struct rect *restrict new_rect, APTR mempool)
Check rect is not already queued for redraw.
int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
static struct Screen * scrn
nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table)
Add a window to the NetSurf window list (to enable event processing)
void * ami_window_at_pointer(int type)
undocumented, or internal, or documented elsewhere
nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox)
Compatibility function to get space.gadget render area.
void ami_gui_free_space_box(struct IBox *bbox)
Free any data obtained via ami_gui_get_space_box().
void ami_gui_win_list_remove(void *win)
Remove a window from the NetSurf window list.
int ami_gui_get_quals(Object *win_obj)
Get which qualifier keys are being pressed.
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
const struct plotter_table amiplot
void ami_plot_ra_free(struct gui_globals *gg)
Free a plotter render area.
struct BitMap * ami_plot_ra_get_bitmap(struct gui_globals *gg)
Get a drawing BitMap associated with a render area.
void ami_plot_ra_get_size(struct gui_globals *gg, int *width, int *height)
Get size of BitMap associated with a render area.
void ami_clearclipreg(struct gui_globals *gg)
struct gui_globals * ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
Alloc a plotter render area.
nserror ami_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
core_window_drag_status
drag status passed to drag_status callback
@ CORE_WINDOW_DRAG_SELECTION
void ami_drag_icon_show(struct Window *win, const char *type)
bool ami_drag_icon_move(void)
void ami_drag_icon_close(struct Window *win)
nserror
Enumeration of error codes.
struct MinList * NewObjList(void)
void FreeObjList(struct MinList *objlist)
struct nsObject * AddObject(struct MinList *objlist, ULONG otype)
void DelObjectNoFree(struct nsObject *dtzo)
void ami_utf8_free(char *ptr)
Core mouse and pointer states.
@ BROWSER_MOUSE_PRESS_1
button 1 pressed
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
@ BROWSER_MOUSE_PRESS_2
button 2 pressed
@ BROWSER_MOUSE_HOVER
No mouse buttons pressed, May be used to indicate hover or end of drag.
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Interface to key press operations.
#define NSLOG(catname, level, logmsg, args...)
#define ami_memory_itempool_create(s)
#define ami_memory_itempool_alloc(p, s)
#define ami_memory_itempool_free(p, i, s)
#define ami_memory_itempool_delete(p)
Localised message support (interface).
struct Node * GetHead(struct List *list)
ULONG RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1,...)
struct Node * GetSucc(struct Node *node)
Minimal compatibility header for AmigaOS 3.
#define IDCMP_EXTENDEDMOUSE
#define IsMinListEmpty(L)
plotter style interfaces, generic styles and style colour helpers.
Interface to utility string handling.
void(* close)(struct ami_corewindow *ami_cw)
callback to close an Amiga core window
Object * objects[GID_CW_LAST]
nserror(* mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x, int y)
callback for mouse event on Amiga core window
nserror(* draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
callback to draw on drawable area of Amiga core window
struct ami_generic_window w
nserror(* key)(struct ami_corewindow *ami_cw, uint32_t nskey)
callback for keypress on Amiga core window
struct MinList * deferred_rects
bool in_border_scroll
keep track of the scrollbar type we're using
BOOL(* event)(struct ami_corewindow *ami_cw, ULONG result)
callback for unknown events on Amiga core window eg.
core_window_drag_status drag_status
drag status set by core
nserror(* drag_end)(struct ami_corewindow *ami_cw, int x, int y)
callback for drag end on Amiga core window ie.
struct gui_globals * gg
stuff for our off-screen render bitmap
char * wintitle
window title, must be allocated wth ami_utf8 function
Core user interface window function table.
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
bool interactive
Redraw to show interactive features.
struct rect rect
Rectangle coordinates.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.