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{
41 NSLOG(netsurf, INFO, "cw %p", cw);
42 return(global_history_init(cw));
43}
44
45static void atari_global_history_finish(struct core_window *cw)
46{
47 NSLOG(netsurf, INFO, "cw %p", cw);
49}
50
51static void atari_global_history_draw(struct core_window *cw, int x,
52 int y, struct rect *clip,
53 const struct redraw_context *ctx)
54{
55 global_history_redraw(x, y, clip, ctx);
56}
57
58static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4)
59{
60 NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4);
62}
63
64static void
65atari_global_history_mouse_action(struct core_window *cw,
67 int x, int y)
68{
69 NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y);
70
71 global_history_mouse_action(mouse, x, y);
72}
73
75{
77}
78
79
80static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
81{
82 short retval = 0;
83
84 NSLOG(netsurf, INFO, "win %p", win);
85
86 if (ev_out->emo_events & MU_MESAG) {
87 switch (msg[0]) {
88 case WM_CLOSED:
90 retval = 1;
91 break;
92
93 default: break;
94 }
95 }
96
97 return(retval);
98}
99
105 .mouse_action = atari_global_history_mouse_action,
106 .gemtk_user_func = handle_event
107};
108
110{
111 if (atari_global_history.init == false) {
112 if( atari_global_history.window == NULL ) {
113 int flags = ATARI_TREEVIEW_WIDGETS;
114 short handle = -1;
115 OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_HISTORY);
116 assert( tree );
117
118 handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
119 atari_global_history.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
120 if( atari_global_history.window == NULL ) {
121 gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
122 "Failed to allocate History");
123 return;
124 }
125 wind_set_str(handle, WF_NAME, (char*)messages_get("History"));
126 gemtk_wm_set_toolbar(atari_global_history.window, tree, 0, 0);
127 gemtk_wm_unlink(atari_global_history.window);
128
132 NULL, flags);
133
134 if (atari_global_history.tv == NULL) {
135 /* handle it properly, clean up previous allocs */
136 NSLOG(netsurf, INFO,
137 "Failed to allocate treeview");
138 return;
139 }
140 }
141 }
143}
144
146{
148
149 if (atari_global_history.init == false) {
150 return;
151 }
152
154
155 GRECT pos;
156 pos.g_x = desk_area.g_w - desk_area.g_w / 4;
157 pos.g_y = desk_area.g_y;
158 pos.g_w = desk_area.g_w / 4;
159 pos.g_h = desk_area.g_h;
160
162 } else {
163 wind_set(gemtk_wm_get_handle(atari_global_history.window), WF_TOP, 1, 0, 0, 0);
164 }
165}
166
167
169{
170
171 if ( atari_global_history.init == false) {
172 return;
173 }
174
175 if ( atari_global_history.window != NULL ) {
178 wind_delete(gemtk_wm_get_handle(atari_global_history.window));
179 gemtk_wm_remove(atari_global_history.window);
183 }
184 NSLOG(netsurf, INFO, "done");
185}
186
188{
190}
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:51
void atari_global_history_open(void)
Definition: history.c:145
void atari_global_history_close(void)
Definition: history.c:74
GRECT desk_area
Definition: gui.c:79
static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4)
Definition: history.c:58
static nserror atari_global_history_init_phase2(struct core_window *cw)
Definition: history.c:39
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
Definition: history.c:80
void atari_global_history_redraw(void)
Definition: history.c:187
static struct atari_treeview_callbacks atari_global_history_treeview_callbacks
Definition: history.c:100
void atari_global_history_init(void)
Definition: history.c:109
void atari_global_history_destroy(void)
Definition: history.c:168
static void atari_global_history_finish(struct core_window *cw)
Definition: history.c:45
static void atari_global_history_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y)
Definition: history.c:65
nserror global_history_init(void *core_window_handle)
Initialise the global history.
nserror global_history_fini(void)
Finalise 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:740
bool atari_treeview_is_open(struct core_window *cw)
Returns the window "open" state.
Definition: treeview.c:780
void atari_treeview_redraw(struct core_window *cw)
Process all pending redraw requests for a single treeview.
Definition: treeview.c:627
void atari_treeview_close(struct core_window *cw)
Closes (hides) the treeview window.
Definition: treeview.c:804
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:547
void atari_treeview_open(struct core_window *cw, GRECT *pos)
Open the treeview window.
Definition: treeview.c:754
#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
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