2017-01-01 16:28:11 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AMIGA_COREWINDOW_H
|
|
|
|
#define AMIGA_COREWINDOW_H
|
|
|
|
|
|
|
|
#include "netsurf/core_window.h"
|
|
|
|
|
|
|
|
#include "amiga/gui.h" /* need to know the size of ami_generic_window :( */
|
|
|
|
#include "amiga/plotters.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BOOPSI objects
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GID_CW_WIN = 0, /* window object */
|
|
|
|
GID_CW_MAIN, /* root layout object */
|
|
|
|
GID_CW_DRAW, /* drawing area (space.gadget) */
|
|
|
|
GID_CW_HSCROLL, /* horizontal scroller */
|
|
|
|
GID_CW_VSCROLL, /* vertical scroller */
|
2017-01-02 21:41:40 +03:00
|
|
|
GID_CW_HSCROLLLAYOUT, /* horizontal scroller container*/
|
|
|
|
GID_CW_VSCROLLLAYOUT, /* vertical scroller container */
|
2017-01-01 16:28:11 +03:00
|
|
|
GID_CW_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Amiga core window state
|
|
|
|
*/
|
|
|
|
struct ami_corewindow {
|
|
|
|
/*
|
|
|
|
* Any variables common to any frontend window would go here.
|
|
|
|
* e.g. drawing area handles, toolkit pointers or other state
|
|
|
|
*/
|
|
|
|
struct ami_generic_window w;
|
|
|
|
struct Window *win;
|
|
|
|
Object *objects[GID_CW_LAST];
|
|
|
|
|
|
|
|
struct Hook idcmp_hook;
|
2017-01-01 19:45:27 +03:00
|
|
|
struct timeval lastclick;
|
2017-01-01 20:26:55 +03:00
|
|
|
|
2017-01-03 23:01:58 +03:00
|
|
|
int mouse_x_click;
|
|
|
|
int mouse_y_click;
|
2017-01-01 19:45:27 +03:00
|
|
|
int mouse_state;
|
2017-01-01 16:28:11 +03:00
|
|
|
|
2017-01-07 03:26:15 +03:00
|
|
|
bool dragging;
|
|
|
|
int drag_x_start;
|
|
|
|
int drag_y_start;
|
|
|
|
|
2017-01-05 21:50:38 +03:00
|
|
|
bool close_window; // set to true to close the window during event loop
|
|
|
|
|
2017-01-02 02:57:35 +03:00
|
|
|
APTR deferred_rects_pool;
|
|
|
|
struct MinList *deferred_rects;
|
|
|
|
|
2017-01-02 21:41:40 +03:00
|
|
|
/** keep track of the scrollbar type we're using */
|
|
|
|
bool in_border_scroll;
|
|
|
|
bool scroll_x_visible;
|
|
|
|
bool scroll_y_visible;
|
|
|
|
|
2017-01-02 18:02:32 +03:00
|
|
|
/** window title, must be allocated wth ami_utf8 function */
|
|
|
|
char *wintitle;
|
|
|
|
|
2017-01-01 16:28:11 +03:00
|
|
|
/** stuff for our off-screen render bitmap */
|
2017-02-13 20:46:20 +03:00
|
|
|
struct gui_globals *gg;
|
2017-01-01 16:28:11 +03:00
|
|
|
struct MinList *shared_pens;
|
|
|
|
|
|
|
|
/** drag status set by core */
|
|
|
|
core_window_drag_status drag_status;
|
|
|
|
|
|
|
|
/** table of callbacks for core window operations */
|
|
|
|
struct core_window_callback_table *cb_table;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* callback to draw on drawable area of Amiga core window
|
|
|
|
*
|
|
|
|
* \param ami_cw The Amiga core window structure.
|
2017-01-02 22:16:33 +03:00
|
|
|
* \param x Plot origin (X)
|
|
|
|
* \param r Plot origin (Y)
|
2017-01-01 16:28:11 +03:00
|
|
|
* \param r The rectangle of the window that needs updating.
|
2017-01-02 22:16:33 +03:00
|
|
|
* \param ctx Redraw context
|
2017-01-01 16:28:11 +03:00
|
|
|
* \return NSERROR_OK on success otherwise apropriate error code
|
|
|
|
*/
|
2017-01-02 22:16:33 +03:00
|
|
|
nserror (*draw)(struct ami_corewindow *ami_cw, int x, int y, struct rect *r,
|
|
|
|
struct redraw_context *ctx);
|
2017-01-01 16:28:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* callback for keypress on Amiga core window
|
|
|
|
*
|
|
|
|
* \param ami_cw The Amiga core window structure.
|
|
|
|
* \param nskey The netsurf key code.
|
|
|
|
* \return NSERROR_OK if key processed,
|
|
|
|
* NSERROR_NOT_IMPLEMENTED if key not processed
|
|
|
|
* otherwise apropriate error code
|
|
|
|
*/
|
|
|
|
nserror (*key)(struct ami_corewindow *ami_cw, uint32_t nskey);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* callback for mouse event on Amiga core window
|
|
|
|
*
|
|
|
|
* \param ami_cw The Amiga core window structure.
|
|
|
|
* \param mouse_state mouse state
|
|
|
|
* \param x location of event
|
|
|
|
* \param y location of event
|
|
|
|
* \return NSERROR_OK on sucess otherwise apropriate error code.
|
|
|
|
*/
|
|
|
|
nserror (*mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x, int y);
|
|
|
|
|
2017-01-01 17:34:04 +03:00
|
|
|
/**
|
|
|
|
* callback for unknown events on Amiga core window
|
|
|
|
* eg. buttons in the ssl cert window
|
2017-01-01 17:53:37 +03:00
|
|
|
* (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP)
|
|
|
|
* (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT)
|
|
|
|
*
|
2017-01-01 17:34:04 +03:00
|
|
|
* \param ami_cw The Amiga core window structure.
|
2017-01-01 17:53:37 +03:00
|
|
|
* \param result event as returned by RA_HandleInput()
|
2017-01-02 15:57:07 +03:00
|
|
|
* \return TRUE if window closed during event processing
|
2017-01-01 17:34:04 +03:00
|
|
|
*/
|
2017-01-02 15:57:07 +03:00
|
|
|
BOOL (*event)(struct ami_corewindow *ami_cw, ULONG result);
|
2017-01-01 17:34:04 +03:00
|
|
|
|
2017-01-07 03:26:15 +03:00
|
|
|
/**
|
|
|
|
* callback for drag end on Amiga core window
|
|
|
|
* ie. a drag *from* this window to a different window
|
|
|
|
*
|
|
|
|
* \param ami_cw The Amiga core window structure.
|
|
|
|
* \param x mouse x position **in screen co-ordinates**
|
|
|
|
* \param y mouse y position **in screen co-ordinates**
|
|
|
|
* \return NSERROR_OK on success otherwise apropriate error code
|
|
|
|
*/
|
|
|
|
nserror (*drag_end)(struct ami_corewindow *ami_cw, int x, int y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* callback for icon drop on Amiga core window
|
|
|
|
* ie. a drag has ended *above* this window
|
|
|
|
* \todo this may not be very flexible but serves our current purposes
|
|
|
|
*
|
|
|
|
* \param ami_cw The Amiga core window structure.
|
|
|
|
* \param url url of dropped icon
|
|
|
|
* \param title title of dropped icon
|
|
|
|
* \param x mouse x position **in screen co-ordinates**
|
|
|
|
* \param y mouse y position **in screen co-ordinates**
|
|
|
|
* \return NSERROR_OK on success otherwise apropriate error code
|
|
|
|
*/
|
|
|
|
nserror (*icon_drop)(struct ami_corewindow *ami_cw, struct nsurl *url, const char *title, int x, int y);
|
|
|
|
|
2017-01-01 16:28:11 +03:00
|
|
|
/**
|
|
|
|
* callback to close an Amiga core window
|
|
|
|
*
|
|
|
|
* \param ami_cw The Amiga core window structure.
|
|
|
|
*/
|
2017-01-02 15:57:07 +03:00
|
|
|
void (*close)(struct ami_corewindow *ami_cw);
|
2017-01-01 16:28:11 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* initialise elements of Amiga core window.
|
|
|
|
*
|
|
|
|
* As a pre-requisite the draw, key and mouse callbacks must be defined
|
|
|
|
*
|
2017-02-19 14:32:17 +03:00
|
|
|
* \param ami_cw An Amiga core window structure to initialise
|
2017-01-01 16:28:11 +03:00
|
|
|
* \return NSERROR_OK on successful initialisation otherwise error code.
|
|
|
|
*/
|
|
|
|
nserror ami_corewindow_init(struct ami_corewindow *ami_cw);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* finalise elements of Amiga core window.
|
|
|
|
*
|
|
|
|
* \param ami_cw An Amiga core window structure to finialise
|
|
|
|
* \return NSERROR_OK on successful finalisation otherwise error code.
|
|
|
|
*/
|
|
|
|
nserror ami_corewindow_fini(struct ami_corewindow *ami_cw);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|