summaryrefslogtreecommitdiff
path: root/frontends/riscos/corewindow.h
blob: b340bde351605316318b8ccb5ea6e55ebed03902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
 *
 * 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/>.
 */

/**
 * \file
 * RISC OS core window interface
 *
 * This module is an object that must be encapsulated. Client users
 * should embed a struct ro_corewindow at the beginning of their
 * context for this display surface, fill in relevant data and then
 * call ro_corewindow_init()
 */

#ifndef NETSURF_RISCOS_COREWINDOW_H
#define NETSURF_RISCOS_COREWINDOW_H

#include "netsurf/core_window.h"

/**
 * ro core window state
 */
struct ro_corewindow {
	/** window handle */
	wimp_w wh;

	/** toolbar */
	struct toolbar *toolbar;

	/** content plot origin y relative to window */
	int origin_y;

	/** content width */
	int content_width;

	/** content height */
	int content_height;

        /** 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 ro core window
         *
         * \param ro_cw The riscos core window structure.
	 * \param originx The risc os plotter x origin.
	 * \param originy The risc os plotter y origin.
         * \param r The rectangle of the window that needs updating.
         * \return NSERROR_OK on success otherwise apropriate error code
         */
        nserror (*draw)(struct ro_corewindow *ro_cw, int originx, int originy, struct rect *r);

        /**
         * callback for keypress on ro core window
         *
         * \param ro_cw The ro 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 ro_corewindow *ro_cw, uint32_t nskey);

        /**
         * callback for mouse event on ro core window
         *
         * \param ro_cw The ro 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 ro_corewindow *ro_cw, browser_mouse_state mouse_state, int x, int y);

	/**
         * callback for clicks in ro core window toolbar.
         *
         * \param ro_cw The ro core window structure.
         * \param action The button bar action.
         * \return NSERROR_OK if config saved, otherwise apropriate error code
         */
        nserror (*toolbar_click)(struct ro_corewindow *ro_cw, button_bar_action action);

	/**
         * callback for updating state of buttons in ro core window toolbar.
         *
         * \param ro_cw The ro core window structure.
         * \return NSERROR_OK if config saved, otherwise apropriate error code
         */
        nserror (*toolbar_update)(struct ro_corewindow *ro_cw);

	/**
         * callback for saving ro core window toolbar state.
         *
         * \param ro_cw The ro core window structure.
         * \param config The new toolbar configuration.
         * \return NSERROR_OK if config saved, otherwise apropriate error code
         */
        nserror (*toolbar_save)(struct ro_corewindow *ro_cw, char *config);

};

/**
 * initialise elements of riscos core window.
 *
 * As a pre-requisite the draw, key and mouse callbacks must be defined
 *
 * \param ro_cw A riscos core window structure to initialise
 * \return NSERROR_OK on successful initialisation otherwise error code.
 */
nserror ro_corewindow_init(struct ro_corewindow *ro_cw, const struct button_bar_buttons *tb_buttons, char *tb_order, theme_style tb_style, const char *tb_help);

/**
 * finalise elements of ro core window.
 *
 * \param ro_cw A riscos core window structure to initialise
 * \return NSERROR_OK on successful finalisation otherwise error code.
 */
nserror ro_corewindow_fini(struct ro_corewindow *ro_cw);


#endif