summaryrefslogtreecommitdiff
path: root/atari/treeview.c
blob: de2a9fcdc1fc47dd9b8ec57b6882821df4e86658 (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*

 * Copyright 2010 Ole Loots <ole@monochrom.net>

 *

 * 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/>.

 */

#include <stdbool.h>

#include <stdint.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>

#include <windom.h>


#include "content/urldb.h"

#include "desktop/browser.h"

#include "desktop/plotters.h"

#include "desktop/textinput.h"

#include "desktop/tree.h"

#include "desktop/tree_url_node.h"

#include "utils/log.h"

#include "utils/messages.h"

#include "utils/utils.h"

#include "atari/gui.h"

#include "atari/treeview.h"


const char tree_directory_icon_name[] = "dir.png";
const char tree_content_icon_name[] = "content.png";

static void atari_treeview_request_redraw(int x,int y,int w,int h,void *pw);
static void atari_treeview_resized(struct tree *tree,int w,int h,void *pw);
static void atari_treeview_scroll_visible(int y, int h, void *pw);
static void atari_treeview_get_dimensions(int *width, int *height,void *pw);

static const struct treeview_table atari_tree_callbacks = {
	atari_treeview_request_redraw,
	atari_treeview_resized,
	atari_treeview_scroll_visible,
	atari_treeview_get_dimensions
};


NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win ) 
{
	LOG(("flags: %d", flags));
	NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
	if (new == NULL)
		return NULL;
	memset( new, 0, sizeof(struct atari_treeview));
	new->tree = tree_create(flags, &atari_tree_callbacks, new);
	if (new->tree == NULL) {
		free(new);
		return NULL;
	}
	new->window = win;
	return(new);
}

void atari_treeview_open( NSTREEVIEW tv )
{
	LOG(("tree: %p", tv));
	if( tv->window != NULL ) {

	}
}

void atari_treeview_close( NSTREEVIEW tv )
{
	if( tv->window != NULL ) {

	}
}

void atari_treeview_destroy( NSTREEVIEW tv ) 
{
	LOG(("tree: %p", tv));
	if( tv->tree != NULL ) {
		tree_delete(tv->tree);
		tv->tree = NULL;
	}
}

struct tree * atari_treeview_get_tree( NSTREEVIEW tv )
{
	return( tv->tree );
}

WINDOW * atari_tree_get_window( NSTREEVIEW tv )
{
	return( tv->window );
}


/**

 * Callback to force a redraw of part of the treeview window.

 *

 * \param  x		Min X Coordinate of area to be redrawn.

 * \param  y		Min Y Coordinate of area to be redrawn.

 * \param  width	Width of area to be redrawn.

 * \param  height	Height of area to be redrawn.

 * \param  pw		The treeview object to be redrawn.

 */
void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
{
	LOG(("tree: %p", pw));
	if (pw != NULL) {
		NSTREEVIEW tv = (NSTREEVIEW) pw;
		tv->redraw.required = true;
	}
}

/**

 * Callback to notify us of a new overall tree size.

 *

 * \param  tree		The tree being resized.

 * \param  width	The new width of the window.

 * \param  height	The new height of the window.

 * \param  *pw		The treeview object to be resized.

 */

void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
{
	LOG(("tree: %p", pw));
	if (pw != NULL) {
		NSTREEVIEW tv = (NSTREEVIEW) pw;
	}
}


/**

 * Callback to request that a section of the tree is scrolled into view.

 *

 * \param  y			The Y coordinate of top of the area in NS units.

 * \param  height		The height of the area in NS units.

 * \param  *pw			The treeview object affected.

 */

void atari_treeview_scroll_visible(int y, int height, void *pw)
{
	LOG(("tree: %p", pw));
	if (pw != NULL) {
		NSTREEVIEW tv = (NSTREEVIEW) pw;
	}
}

/**

 * Callback to return the tree window dimensions to the treeview system.

 *

 * \param  *width		Return the window width.

 * \param  *height		Return the window height.

 * \param  *pw			The treeview object to use.

 */

void atari_treeview_get_dimensions(int *width, int *height,
		void *pw)
{
	LOG(("tree: %p", pw));
	if (pw != NULL && (width != NULL || height != NULL)) {
		NSTREEVIEW tv = (NSTREEVIEW) pw;
	}
}


/**

 * Translates a content_type to the name of a respective icon

 *

 * \param content_type	content type

 * \param buffer	buffer for the icon name

 */
void tree_icon_name_from_content_type(char *buffer, content_type type)
{
	switch (type) {
		case CONTENT_HTML:
		case CONTENT_TEXTPLAIN:
		case CONTENT_CSS:
#if defined(WITH_MNG) || defined(WITH_PNG)

		case CONTENT_PNG:
#endif

#ifdef WITH_MNG

		case CONTENT_JNG:
		case CONTENT_MNG:
#endif

#ifdef WITH_JPEG

		case CONTENT_JPEG:
#endif

#ifdef WITH_GIF

		case CONTENT_GIF:
#endif

#ifdef WITH_BMP

		case CONTENT_BMP:
		case CONTENT_ICO:
#endif

#ifdef WITH_SPRITE

		case CONTENT_SPRITE:
#endif

#ifdef WITH_DRAW

		case CONTENT_DRAW:
#endif

#ifdef WITH_ARTWORKS

		case CONTENT_ARTWORKS:
#endif

#ifdef WITH_NS_SVG

		case CONTENT_SVG:
#endif

		default:
			sprintf(buffer, tree_content_icon_name);
			break;
	}
}