NetSurf
history.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ole Loots <ole@monochrom.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <assert.h>
20#include <inttypes.h>
21
22#include "utils/log.h"
23#include "utils/messages.h"
24#include "netsurf/mouse.h"
26
27#include "atari/treeview.h"
28#include "atari/history.h"
29#include "atari/gemtk/gemtk.h"
30#include "atari/res/netsurf.rsh"
31
32extern GRECT desk_area;
33
35
36/* Setup Atari Treeview Callbacks: */
37
38static nserror
39atari_global_history_init_phase2(struct core_window *cw,
40 struct core_window_callback_table *cb_t)
41{
42 NSLOG(netsurf, INFO, "cw %p", cw);
43 return(global_history_init(cb_t, cw));
44}
45
46static void atari_global_history_finish(struct core_window *cw)
47{
48 NSLOG(netsurf, INFO, "cw %p", cw);
50}
51
52static void atari_global_history_draw(struct core_window *cw, int x,
53 int y, struct rect *clip,
54 const struct redraw_context *ctx)
55{
56 global_history_redraw(x, y, clip, ctx);
57}
58
59static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4)
60{
61 NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4);
63}
64
65static void
66atari_global_history_mouse_action(struct core_window *cw,
68 int x, int y)
69{
70 NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y);
71
72 global_history_mouse_action(mouse, x, y);
73}
74
76{
78}
79
80
81static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
82{
83 short retval = 0;
84
85 NSLOG(netsurf, INFO, "win %p", win);
86
87 if (ev_out->emo_events & MU_MESAG) {
88 switch (msg[0]) {
89 case WM_CLOSED:
91 retval = 1;
92 break;
93
94 default: break;
95 }
96 }
97
98 return(retval);
99}
100
106 .mouse_action = atari_global_history_mouse_action,
107 .gemtk_user_func = handle_event
108};
109
111{
112 if (atari_global_history.init == false) {
113 if( atari_global_history.window == NULL ) {
114 int flags = ATARI_TREEVIEW_WIDGETS;
115 short handle = -1;
116 OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_HISTORY);
117 assert( tree );
118
119 handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
120 atari_global_history.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
121 if( atari_global_history.window == NULL ) {
122 gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
123 "Failed to allocate History");
124 return;
125 }
126 wind_set_str(handle, WF_NAME, (char*)messages_get("History"));
127 gemtk_wm_set_toolbar(atari_global_history.window, tree, 0, 0);
128 gemtk_wm_unlink(atari_global_history.window);
129
133 NULL, flags);
134
135 if (atari_global_history.tv == NULL) {
136 /* handle it properly, clean up previous allocs */
137 NSLOG(netsurf, INFO,
138 "Failed to allocate treeview");
139 return;
140 }
141 }
142 }
144}
145
147{
149
150 if (atari_global_history.init == false) {
151 return;
152 }
153
155
156 GRECT pos;
157 pos.g_x = desk_area.g_w - desk_area.g_w / 4;
158 pos.g_y = desk_area.g_y;
159 pos.g_w = desk_area.g_w / 4;
160 pos.g_h = desk_area.g_h;
161
163 } else {
164 wind_set(gemtk_wm_get_handle(atari_global_history.window), WF_TOP, 1, 0, 0, 0);
165 }
166}
167
168
170{
171
172 if ( atari_global_history.init == false) {
173 return;
174 }
175
176 if ( atari_global_history.window != NULL ) {
179 wind_delete(gemtk_wm_get_handle(atari_global_history.window));
180 gemtk_wm_remove(atari_global_history.window);
184 }
185 NSLOG(netsurf, INFO, "done");
186}
187
189{
191}
struct atari_global_history_s atari_global_history
Definition: history.c:34
static void atari_global_history_draw(struct core_window *cw, int x, int y, struct rect *clip, const struct redraw_context *ctx)
Definition: history.c:52
void atari_global_history_open(void)
Definition: history.c:146
void atari_global_history_close(void)
Definition: history.c:75
static nserror atari_global_history_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t)
Definition: history.c:39
GRECT desk_area
Definition: gui.c:78
static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4)
Definition: history.c:59
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
Definition: history.c:81
void atari_global_history_redraw(void)
Definition: history.c:188
static struct atari_treeview_callbacks atari_global_history_treeview_callbacks
Definition: history.c:101
void atari_global_history_init(void)
Definition: history.c:110
void atari_global_history_destroy(void)
Definition: history.c:169
static void atari_global_history_finish(struct core_window *cw)
Definition: history.c:46
static void atari_global_history_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y)
Definition: history.c:66
nserror global_history_fini(void)
Finalise the global history.
nserror global_history_init(struct core_window_callback_table *cw_t, void *core_window_handle)
Initialise the global history.
void global_history_redraw(int x, int y, struct rect *clip, const struct redraw_context *ctx)
Redraw the global history.
bool global_history_keypress(uint32_t key)
Key press handling.
void global_history_mouse_action(browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
nserror
Enumeration of error codes.
Definition: errors.h:29
void atari_treeview_delete(struct core_window *cw)
Free the Treeview, but not the gemtk window used for the treeview.
Definition: treeview.c:739
bool atari_treeview_is_open(struct core_window *cw)
Returns the window "open" state.
Definition: treeview.c:779
void atari_treeview_redraw(struct core_window *cw)
Process all pending redraw requests for a single treeview.
Definition: treeview.c:626
void atari_treeview_close(struct core_window *cw)
Closes (hides) the treeview window.
Definition: treeview.c:803
struct core_window * atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks *callbacks, void *user_data, uint32_t flags)
Initalize an window to be an treeview window.
Definition: treeview.c:546
void atari_treeview_open(struct core_window *cw, GRECT *pos)
Open the treeview window.
Definition: treeview.c:753
#define ATARI_TREEVIEW_WIDGETS
Default AES Window widgets for a treeview window, can be passed to atari_treeview_create as the flags...
Definition: treeview.h:32
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
Netsurf additional integer type formatting macros.
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
struct core_window * tv
Definition: history.h:27
atari_treeview_init2_callback init_phase2
Definition: treeview.h:60
Callbacks to achieve various core window functionality.
Definition: core_window.h:51
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357