Replaced atari_treeview wrapper with a new one
(removed all modules which used the old tree API)
This commit is contained in:
parent
05f13ccf89
commit
8057dc67cb
|
@ -40,7 +40,7 @@ $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng)))
|
|||
$(eval $(call feature_enabled,MOZJS,$(SPIDERMONKEY_CFLAGS),-ljs,JavaScript (Spidermonkey)))
|
||||
$(eval $(call feature_enabled,ATARI_FREETYPE_FONT,$(FREETYPE_FONT_CFLAGS),-lfreetype,(Freetype)))
|
||||
$(eval $(call feature_enabled,ATARI_NETSURF_FONT,-DWITH_INTERNAL_FONT_DRIVER,,(Internal Font)))
|
||||
$(eval $(call feature_enabled,ATARI_VDI_FONT,-DWITH_VDI_FONT_DRIVER,,(Internal Font)))
|
||||
$(eval $(call feature_enabled,ATARI_VDI_FONT,-DWITH_VDI_FONT_DRIVER,,(VDI Font)))
|
||||
$(eval $(call feature_enabled,ATARI_8BPP_SUPPORT,-DWITH_8BPP_SUPPORT,,(Indexed screen format support)))
|
||||
|
||||
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
|
||||
|
@ -77,28 +77,26 @@ LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
|
|||
S_ATARI := \
|
||||
bitmap.c \
|
||||
clipboard.c \
|
||||
ctxmenu.c \
|
||||
deskmenu.c \
|
||||
download.c \
|
||||
encoding.c \
|
||||
findfile.c \
|
||||
filetype.c \
|
||||
font.c \
|
||||
gui.c \
|
||||
misc.c \
|
||||
schedule.c \
|
||||
download.c \
|
||||
thumbnail.c \
|
||||
login.c \
|
||||
treeview.c \
|
||||
hotlist.c \
|
||||
history.c\
|
||||
misc.c \
|
||||
osspec.c \
|
||||
schedule.c \
|
||||
search.c \
|
||||
statusbar.c \
|
||||
thumbnail.c \
|
||||
treeview.c \
|
||||
redrawslots.c \
|
||||
encoding.c \
|
||||
rootwin.c \
|
||||
toolbar.c \
|
||||
statusbar.c \
|
||||
osspec.c \
|
||||
ctxmenu.c \
|
||||
settings.c \
|
||||
deskmenu.c \
|
||||
plot/plot.c \
|
||||
plot/fontplot.c \
|
||||
plot/eddi.s \
|
||||
|
@ -112,6 +110,10 @@ S_ATARI := \
|
|||
gemtk/utils.c \
|
||||
gemtk/objc.c
|
||||
|
||||
# cookies.c \
|
||||
# hotlist.c \
|
||||
# history.c\
|
||||
|
||||
S_ATARI := $(addprefix atari/,$(S_ATARI))
|
||||
|
||||
# This is the final source build list
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
# Atari target setup
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(ATARI_ARCH),68000)
|
||||
PRGSUFFIX := 000.app
|
||||
PKGNAME := ns000.zip
|
||||
endif
|
||||
|
||||
ifeq ($(ATARI_ARCH),68020-60)
|
||||
CFLAGS += -m68020-60
|
||||
LDFLAGS += -m68020-60
|
||||
PRGSUFFIX := 020.app
|
||||
PKGNAME := ns020.zip
|
||||
endif
|
||||
|
||||
ifeq ($(ATARI_ARCH),5475)
|
||||
CFLAGS += -mcpu=5475
|
||||
LDFLAGS += -mcpu=5475
|
||||
PRGSUFFIX := v4e.app
|
||||
PKGNAME := nsv4e.zip
|
||||
endif
|
||||
|
||||
# non-pkgconfig components
|
||||
|
||||
FREETYPE_FONT_CFLAGS := $(shell freetype-config --cflags) -DWITH_FREETYPE_FONT_DRIVER
|
||||
SPIDERMONKEY_CFLAGS := -DWITH_MOZJS -DXP_UNIX -DJS_HAS_FILE_OBJECT=0 -DJSOPTION_JIT=0 -DPOSIX_SOURCE -D_BSD_SOURCE
|
||||
|
||||
$(eval $(call feature_enabled,MNG,-DWITH_MNG,-lmng,PNG/MNG/JNG (libmng)))
|
||||
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng)))
|
||||
$(eval $(call feature_enabled,MOZJS,$(SPIDERMONKEY_CFLAGS),-ljs,JavaScript (Spidermonkey)))
|
||||
$(eval $(call feature_enabled,ATARI_FREETYPE_FONT,$(FREETYPE_FONT_CFLAGS),-lfreetype,(Freetype)))
|
||||
$(eval $(call feature_enabled,ATARI_NETSURF_FONT,-DWITH_INTERNAL_FONT_DRIVER,,(Internal Font)))
|
||||
$(eval $(call feature_enabled,ATARI_8BPP_SUPPORT,-DWITH_8BPP_SUPPORT,,(Indexed screen format support)))
|
||||
|
||||
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
|
||||
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
|
||||
NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
|
||||
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
|
||||
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
|
||||
NETSURF_FEATURE_JS_CFLAGS := -DWITH_JS -DJS_HAS_FILE_OBJECT=0
|
||||
NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0
|
||||
|
||||
ifeq ($(NETSURF_USE_MOZJS),YES)
|
||||
NETSURF_USE_JS:=YES
|
||||
NETSURF_USE_MOZJS:=YES
|
||||
endif
|
||||
|
||||
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP))
|
||||
$(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
|
||||
|
||||
CFLAGS += -U__STRICT_ANSI__ -std=c99 -I. -Dsmall $(WARNFLAGS) -Dnsatari \
|
||||
-D_BSD_SOURCE \
|
||||
-D_XOPEN_SOURCE=600 \
|
||||
-D_POSIX_C_SOURCE=200112L \
|
||||
$(shell $(PKG_CONFIG) --cflags libhubbub libcss openssl ) \
|
||||
$(shell $(PKG_CONFIG) --cflags libxml-2.0 ) \
|
||||
$(shell $(PKG_CONFIG) --cflags libcurl )
|
||||
|
||||
LDFLAGS += -lcflib -lcurl
|
||||
LDFLAGS += -lcss -lparserutils -ldom -lwapcaplet -lhubbub
|
||||
LDFLAGS += -lssl -lcrypto
|
||||
LDFLAGS += -lxml2 -lz -liconv -lcares -lHermes -lwindom -lgem -lm
|
||||
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
|
||||
|
||||
|
||||
# S_ATARI are sources purely for the Atari FreeMiNT build
|
||||
S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
|
||||
download.c thumbnail.c login.c verify_ssl.c treeview.c hotlist.c history.c\
|
||||
search.c font.c \
|
||||
plot/plot.c plot/fontplot.c plot/eddi.s \
|
||||
plot/font_freetype.c plot/font_internal.c \
|
||||
redrawslots.c encoding.c \
|
||||
browser_win.c toolbar.c statusbar.c browser.c \
|
||||
global_evnt.c osspec.c dragdrop.c system_colour.c \
|
||||
ctxmenu.c save.c settings.c
|
||||
S_ATARI := $(addprefix atari/,$(S_ATARI))
|
||||
|
||||
# This is the final source build list
|
||||
# Note this is deliberately *not* expanded here as common and image
|
||||
# are not yet available
|
||||
SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_ATARI)
|
||||
EXETARGET := ns$(SUBTARGET)$(PRGSUFFIX)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Install target
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
install-atari:
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Package target
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
package-atari:
|
||||
=======
|
||||
ATARI_INSTALL_TARGET_DIR := nsatari.package
|
||||
ATARI_RES_DIR := atari/res
|
||||
|
||||
install-atari: $(PKGNAME)
|
||||
$(VQ)echo Creating $(PKGNAME)
|
||||
|
||||
$(PKGNAME): $(EXETARGET)
|
||||
$(Q)rm -rf $(ATARI_INSTALL_TARGET_DIR)
|
||||
$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/
|
||||
$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/netsurf
|
||||
$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/netsurf/doc
|
||||
$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/netsurf/download
|
||||
$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/netsurf/res
|
||||
$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/netsurf/res/fonts
|
||||
#$(Q)mkdir $(ATARI_INSTALL_TARGET_DIR)/netsurf/res/icons
|
||||
$(Q)touch $(ATARI_INSTALL_TARGET_DIR)/netsurf/res/cookies
|
||||
$(Q)cp $(ATARI_RES_DIR)/netsurf.rsc $(ATARI_INSTALL_TARGET_DIR)/netsurf/res/netsurf.rsc
|
||||
$(Q)cp $(ATARI_RES_DIR)/icons/ $(ATARI_INSTALL_TARGET_DIR)/netsurf/res/icons/ -R
|
||||
|
||||
|
||||
$(Q)cp $(EXETARGET) $(ATARI_INSTALL_TARGET_DIR)/netsurf
|
||||
|
||||
>>>>>>> Stashed changes
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright 2013 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/>.
|
||||
*/
|
|
@ -1,168 +1,17 @@
|
|||
/*
|
||||
* 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/>.
|
||||
/*
|
||||
* Copyright 2013 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 <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/global_history.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/messages.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "utils/log.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/findfile.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
#include "atari/history.h"
|
||||
|
||||
|
||||
//TODO: remove/add guiwin handle on close / open - so that the list
|
||||
// is kept tiny.
|
||||
|
||||
extern GRECT desk_area;
|
||||
|
||||
struct s_atari_global_history gl_history;
|
||||
|
||||
|
||||
void atari_global_history_open( void )
|
||||
{
|
||||
atari_global_history_init();
|
||||
if (gl_history.init == false ) {
|
||||
return;
|
||||
}
|
||||
if( gl_history.open == false ) {
|
||||
|
||||
GRECT pos;
|
||||
wind_get_grect(0, WF_WORKXYWH, &pos);
|
||||
pos.g_x = desk_area.g_w - desk_area.g_w / 4;
|
||||
pos.g_y = desk_area.g_y;
|
||||
pos.g_w = desk_area.g_w / 4;
|
||||
pos.g_h = desk_area.g_h;
|
||||
|
||||
wind_open(gemtk_wm_get_handle(gl_history.window), pos.g_x, pos.g_y,
|
||||
pos.g_w, pos.g_h);
|
||||
gl_history.open = true;
|
||||
atari_treeview_open(gl_history.tv);
|
||||
} else {
|
||||
wind_set(gemtk_wm_get_handle(gl_history.window), WF_TOP, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void atari_global_history_close( void )
|
||||
{
|
||||
wind_close(gemtk_wm_get_handle(gl_history.window));
|
||||
gl_history.open = false;
|
||||
atari_treeview_close(gl_history.tv);
|
||||
}
|
||||
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
NSTREEVIEW tv=NULL;
|
||||
|
||||
//printf("Hotlist event %d, open: %d\n", ev_out->emo_events, gl_history.open);
|
||||
|
||||
if(ev_out->emo_events & MU_MESAG){
|
||||
switch (msg[0]) {
|
||||
|
||||
case WM_CLOSED:
|
||||
atari_global_history_close();
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement selectable objects in toolbar API:
|
||||
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
|
||||
}
|
||||
|
||||
bool atari_global_history_init( void )
|
||||
{
|
||||
|
||||
if( gl_history.init == false ) {
|
||||
|
||||
short handle;
|
||||
GRECT desk;
|
||||
int flags = ATARI_TREEVIEW_WIDGETS;
|
||||
|
||||
// initialize state options:
|
||||
gl_history.open = false;
|
||||
|
||||
// Create an AES window:
|
||||
handle = wind_create(flags, 40, 40, desk_area.g_w, desk_area.g_h);
|
||||
|
||||
// add the AES window to the gemtk window manager:
|
||||
gl_history.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
|
||||
|
||||
if( gl_history.window == NULL ) {
|
||||
LOG(("Failed to allocate history window"));
|
||||
return( false );
|
||||
}
|
||||
|
||||
// Set window title:
|
||||
wind_set_str(handle, WF_NAME, (char*)messages_get("GlobalHistory"));
|
||||
|
||||
// Make the window part of the netsurf treeview framework:
|
||||
gl_history.tv = atari_treeview_create(TREE_HISTORY,
|
||||
gl_history.window, handle_event);
|
||||
|
||||
gemtk_wm_unlink(gl_history.window);
|
||||
|
||||
if (gl_history.tv == NULL) {
|
||||
/* TODO: handle it properly, clean up previous allocs */
|
||||
LOG(("Failed to allocate history treeview"));
|
||||
return( false );
|
||||
}
|
||||
|
||||
gl_history.init = true;
|
||||
}
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
||||
void atari_global_history_destroy( void )
|
||||
{
|
||||
|
||||
if( gl_history.init == false ) {
|
||||
return;
|
||||
}
|
||||
if( gl_history.window != NULL ) {
|
||||
if( gl_history.open )
|
||||
atari_global_history_close();
|
||||
wind_delete(gemtk_wm_get_handle(gl_history.window));
|
||||
gemtk_wm_remove(gl_history.window);
|
||||
gl_history.window = NULL;
|
||||
atari_treeview_destroy(gl_history.tv);
|
||||
gl_history.init = false;
|
||||
}
|
||||
LOG(("done"));
|
||||
}
|
||||
|
||||
void atari_global_history_redraw( void )
|
||||
{
|
||||
atari_treeview_redraw( gl_history.tv );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_HISTORY_H
|
||||
#define NS_ATARI_HISTORY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "desktop/tree.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
|
||||
struct s_atari_global_history {
|
||||
GUIWIN *window; /*< The GEMTK window ref */
|
||||
NSTREEVIEW tv; /*< The history treeview handle. */
|
||||
bool open;
|
||||
bool init;
|
||||
};
|
||||
|
||||
extern struct s_atari_global_history gl_history;
|
||||
|
||||
bool atari_global_history_init( void );
|
||||
void atari_global_history_destroy( void );
|
||||
void atari_global_history_open( void );
|
||||
void atari_global_history_close( void );
|
||||
|
||||
void atari_global_history_redraw( void );
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,226 +1,17 @@
|
|||
/*
|
||||
* 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/>.
|
||||
/*
|
||||
* Copyright 2013 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 <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "desktop/browser.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/hotlist.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/url.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/hotlist.h"
|
||||
#include "atari/findfile.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
|
||||
extern GRECT desk_area;
|
||||
|
||||
struct atari_hotlist hl;
|
||||
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
NSTREEVIEW tv=NULL;
|
||||
GRECT tb_area;
|
||||
|
||||
if(ev_out->emo_events & MU_MESAG){
|
||||
switch (msg[0]) {
|
||||
|
||||
case WM_TOOLBAR:
|
||||
|
||||
tv = (NSTREEVIEW) gemtk_wm_get_user_data(win);
|
||||
|
||||
switch (msg[4]) {
|
||||
case TOOLBAR_HOTLIST_CREATE_FOLDER:
|
||||
hotlist_add_folder(NULL, false, 0);
|
||||
break;
|
||||
|
||||
case TOOLBAR_HOTLIST_ADD:
|
||||
atari_hotlist_add_page(NULL, NULL);
|
||||
break;
|
||||
|
||||
case TOOLBAR_HOTLIST_DELETE:
|
||||
hotlist_keypress(KEY_DELETE_LEFT);
|
||||
gemtk_wm_exec_redraw(tv->window, NULL);
|
||||
break;
|
||||
|
||||
case TOOLBAR_HOTLIST_EDIT:
|
||||
hotlist_edit_selection();
|
||||
break;
|
||||
}
|
||||
|
||||
gemtk_obj_get_tree(TOOLBAR_HOTLIST)[msg[4]].ob_state &= ~OS_SELECTED;
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, &tb_area);
|
||||
evnt_timer(150);
|
||||
gemtk_wm_exec_redraw(tv->window, &tb_area);
|
||||
break;
|
||||
|
||||
case WM_CLOSED:
|
||||
atari_hotlist_close();
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement selectable objects in toolbar API:
|
||||
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void atari_hotlist_init(void)
|
||||
{
|
||||
if (hl.init == false) {
|
||||
if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){
|
||||
atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" );
|
||||
} else {
|
||||
strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 );
|
||||
}
|
||||
|
||||
LOG(("Hotlist: %s", (char*)&hl.path ));
|
||||
|
||||
if( hl.window == NULL ){
|
||||
int flags = ATARI_TREEVIEW_WIDGETS;
|
||||
short handle = -1;
|
||||
GRECT desk;
|
||||
OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_HOTLIST);
|
||||
assert( tree );
|
||||
hl.open = false;
|
||||
|
||||
handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
|
||||
hl.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
|
||||
if( hl.window == NULL ) {
|
||||
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
|
||||
"Failed to allocate Hotlist");
|
||||
return;
|
||||
}
|
||||
wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
|
||||
gemtk_wm_set_toolbar(hl.window, tree, 0, 0);
|
||||
gemtk_wm_unlink(hl.window);
|
||||
tree_hotlist_path = (const char*)&hl.path;
|
||||
hl.tv = atari_treeview_create(
|
||||
TREE_HOTLIST,
|
||||
hl.window,
|
||||
handle_event
|
||||
);
|
||||
if (hl.tv == NULL) {
|
||||
/* handle it properly, clean up previous allocs */
|
||||
LOG(("Failed to allocate treeview"));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
hl.init = true;
|
||||
}
|
||||
|
||||
|
||||
void atari_hotlist_open(void)
|
||||
{
|
||||
if( hl.init == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( hl.open == false ) {
|
||||
|
||||
GRECT pos;
|
||||
pos.g_x = desk_area.g_w - desk_area.g_w / 4;
|
||||
pos.g_y = desk_area.g_y;
|
||||
pos.g_w = desk_area.g_w / 4;
|
||||
pos.g_h = desk_area.g_h;
|
||||
|
||||
wind_open_grect(gemtk_wm_get_handle(hl.window), &pos);
|
||||
hl.open = true;
|
||||
atari_treeview_open( hl.tv );
|
||||
} else {
|
||||
wind_set(gemtk_wm_get_handle(hl.window), WF_TOP, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void atari_hotlist_close(void)
|
||||
{
|
||||
wind_close(gemtk_wm_get_handle(hl.window));
|
||||
hl.open = false;
|
||||
atari_treeview_close(hl.tv);
|
||||
}
|
||||
|
||||
void atari_hotlist_destroy(void)
|
||||
{
|
||||
|
||||
if( hl.init == false) {
|
||||
return;
|
||||
}
|
||||
if( hl.window != NULL ) {
|
||||
if (hl.open)
|
||||
atari_hotlist_close();
|
||||
wind_delete(gemtk_wm_get_handle(hl.window));
|
||||
gemtk_wm_remove(hl.window);
|
||||
hl.window = NULL;
|
||||
atari_treeview_destroy(hl.tv);
|
||||
hl.init = false;
|
||||
}
|
||||
LOG(("done"));
|
||||
}
|
||||
|
||||
void atari_hotlist_redraw(void)
|
||||
{
|
||||
int i = 01;
|
||||
atari_treeview_redraw(hl.tv);
|
||||
}
|
||||
|
||||
struct node;
|
||||
|
||||
void atari_hotlist_add_page( const char * url, const char * title )
|
||||
{
|
||||
struct node * root;
|
||||
struct node * selected = NULL;
|
||||
struct node * folder = NULL;
|
||||
nsurl *nsurl;
|
||||
NSTREEVIEW tv = hl.tv;
|
||||
if(hl.tv == NULL )
|
||||
return;
|
||||
|
||||
atari_hotlist_open();
|
||||
|
||||
if (nsurl_create(url, &nsurl) != NSERROR_OK)
|
||||
return;
|
||||
|
||||
if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){
|
||||
hotlist_add_entry( nsurl, title, true, hl.tv->click.y );
|
||||
} else {
|
||||
hotlist_add_url( nsurl );
|
||||
}
|
||||
nsurl_unref(nsurl);
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_HOTLIST_H
|
||||
#define NS_ATARI_HOTLIST_H
|
||||
#include <stdbool.h>
|
||||
#include "desktop/tree.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/treeview.h"
|
||||
/* The hotlist window, toolbar and treeview data. */
|
||||
|
||||
struct atari_hotlist {
|
||||
GUIWIN * window;
|
||||
NSTREEVIEW tv; /*< The hotlist treeview handle. */
|
||||
bool open;
|
||||
bool init;
|
||||
char path[PATH_MAX];
|
||||
};
|
||||
|
||||
extern struct atari_hotlist hl;
|
||||
|
||||
void atari_hotlist_init( void );
|
||||
void atari_hotlist_open( void );
|
||||
void atari_hotlist_close( void );
|
||||
void atari_hotlist_destroy( void );
|
||||
void atari_hotlist_add_page( const char * url, const char * title );
|
||||
|
||||
void atari_hotlist_redraw( void );
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* 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 <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/global_history.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/messages.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "utils/log.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/findfile.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
#include "atari/history.h"
|
||||
|
||||
|
||||
//TODO: remove/add guiwin handle on close / open - so that the list
|
||||
// is kept tiny.
|
||||
|
||||
extern GRECT desk_area;
|
||||
|
||||
struct s_atari_global_history gl_history;
|
||||
|
||||
|
||||
void atari_global_history_open( void )
|
||||
{
|
||||
/* TODO: call this in gui.c and move global_history_init() into history.c */
|
||||
atari_global_history_init();
|
||||
if (gl_history.init == false ) {
|
||||
return;
|
||||
}
|
||||
if( gl_history.open == false ) {
|
||||
|
||||
GRECT pos;
|
||||
wind_get_grect(0, WF_WORKXYWH, &pos);
|
||||
pos.g_x = desk_area.g_w - desk_area.g_w / 4;
|
||||
pos.g_y = desk_area.g_y;
|
||||
pos.g_w = desk_area.g_w / 4;
|
||||
pos.g_h = desk_area.g_h;
|
||||
|
||||
wind_open(gemtk_wm_get_handle(gl_history.window), pos.g_x, pos.g_y,
|
||||
pos.g_w, pos.g_h);
|
||||
gl_history.open = true;
|
||||
atari_treeview_open(gl_history.tv);
|
||||
} else {
|
||||
wind_set(gemtk_wm_get_handle(gl_history.window), WF_TOP, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void atari_global_history_close( void )
|
||||
{
|
||||
wind_close(gemtk_wm_get_handle(gl_history.window));
|
||||
gl_history.open = false;
|
||||
atari_treeview_close(gl_history.tv);
|
||||
}
|
||||
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
NSTREEVIEW tv=NULL;
|
||||
|
||||
//printf("Hotlist event %d, open: %d\n", ev_out->emo_events, gl_history.open);
|
||||
|
||||
if(ev_out->emo_events & MU_MESAG){
|
||||
switch (msg[0]) {
|
||||
|
||||
case WM_CLOSED:
|
||||
atari_global_history_close();
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement selectable objects in toolbar API:
|
||||
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
|
||||
}
|
||||
|
||||
/* TODO: add call to global_history_init() */
|
||||
bool atari_global_history_init( void )
|
||||
{
|
||||
|
||||
if( gl_history.init == false ) {
|
||||
|
||||
short handle;
|
||||
GRECT desk;
|
||||
int flags = ATARI_TREEVIEW_WIDGETS;
|
||||
|
||||
// initialize state options:
|
||||
gl_history.open = false;
|
||||
|
||||
// Create an AES window:
|
||||
handle = wind_create(flags, 40, 40, desk_area.g_w, desk_area.g_h);
|
||||
|
||||
// add the AES window to the gemtk window manager:
|
||||
gl_history.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
|
||||
|
||||
if( gl_history.window == NULL ) {
|
||||
LOG(("Failed to allocate history window"));
|
||||
return( false );
|
||||
}
|
||||
|
||||
// Set window title:
|
||||
wind_set_str(handle, WF_NAME, (char*)messages_get("GlobalHistory"));
|
||||
|
||||
// Make the window part of the netsurf treeview framework:
|
||||
gl_history.tv = atari_treeview_create(TREE_HISTORY,
|
||||
gl_history.window, handle_event);
|
||||
|
||||
gemtk_wm_unlink(gl_history.window);
|
||||
|
||||
if (gl_history.tv == NULL) {
|
||||
/* TODO: handle it properly, clean up previous allocs */
|
||||
LOG(("Failed to allocate history treeview"));
|
||||
return( false );
|
||||
}
|
||||
|
||||
gl_history.init = true;
|
||||
}
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
||||
void atari_global_history_destroy( void )
|
||||
{
|
||||
|
||||
if( gl_history.init == false ) {
|
||||
return;
|
||||
}
|
||||
if( gl_history.window != NULL ) {
|
||||
if( gl_history.open )
|
||||
atari_global_history_close();
|
||||
wind_delete(gemtk_wm_get_handle(gl_history.window));
|
||||
gemtk_wm_remove(gl_history.window);
|
||||
gl_history.window = NULL;
|
||||
atari_treeview_destroy(gl_history.tv);
|
||||
gl_history.init = false;
|
||||
}
|
||||
LOG(("done"));
|
||||
}
|
||||
|
||||
void atari_global_history_redraw( void )
|
||||
{
|
||||
atari_treeview_redraw( gl_history.tv );
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_HISTORY_H
|
||||
#define NS_ATARI_HISTORY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "desktop/tree.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
|
||||
struct s_atari_global_history {
|
||||
GUIWIN *window; /*< The GEMTK window ref */
|
||||
NSTREEVIEW tv; /*< The history treeview handle. */
|
||||
bool open;
|
||||
bool init;
|
||||
};
|
||||
|
||||
extern struct s_atari_global_history gl_history;
|
||||
|
||||
bool atari_global_history_init( void );
|
||||
void atari_global_history_destroy( void );
|
||||
void atari_global_history_open( void );
|
||||
void atari_global_history_close( void );
|
||||
|
||||
void atari_global_history_redraw( void );
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "desktop/browser.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/hotlist.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/url.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/hotlist.h"
|
||||
#include "atari/findfile.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
|
||||
extern GRECT desk_area;
|
||||
|
||||
struct atari_hotlist hl;
|
||||
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
NSTREEVIEW tv=NULL;
|
||||
GRECT tb_area;
|
||||
|
||||
if(ev_out->emo_events & MU_MESAG){
|
||||
switch (msg[0]) {
|
||||
|
||||
case WM_TOOLBAR:
|
||||
|
||||
tv = (NSTREEVIEW) gemtk_wm_get_user_data(win);
|
||||
|
||||
switch (msg[4]) {
|
||||
case TOOLBAR_HOTLIST_CREATE_FOLDER:
|
||||
hotlist_add_folder(NULL, false, 0);
|
||||
break;
|
||||
|
||||
case TOOLBAR_HOTLIST_ADD:
|
||||
atari_hotlist_add_page(NULL, NULL);
|
||||
break;
|
||||
|
||||
case TOOLBAR_HOTLIST_DELETE:
|
||||
hotlist_keypress(KEY_DELETE_LEFT);
|
||||
gemtk_wm_exec_redraw(tv->window, NULL);
|
||||
break;
|
||||
|
||||
case TOOLBAR_HOTLIST_EDIT:
|
||||
hotlist_edit_selection();
|
||||
break;
|
||||
}
|
||||
|
||||
gemtk_obj_get_tree(TOOLBAR_HOTLIST)[msg[4]].ob_state &= ~OS_SELECTED;
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, &tb_area);
|
||||
evnt_timer(150);
|
||||
gemtk_wm_exec_redraw(tv->window, &tb_area);
|
||||
break;
|
||||
|
||||
case WM_CLOSED:
|
||||
atari_hotlist_close();
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement selectable objects in toolbar API:
|
||||
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void atari_hotlist_init(void)
|
||||
{
|
||||
if (hl.init == false) {
|
||||
if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){
|
||||
atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" );
|
||||
} else {
|
||||
strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 );
|
||||
}
|
||||
|
||||
LOG(("Hotlist: %s", (char*)&hl.path ));
|
||||
|
||||
if( hl.window == NULL ){
|
||||
int flags = ATARI_TREEVIEW_WIDGETS;
|
||||
short handle = -1;
|
||||
GRECT desk;
|
||||
OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_HOTLIST);
|
||||
assert( tree );
|
||||
hl.open = false;
|
||||
|
||||
handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
|
||||
hl.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
|
||||
if( hl.window == NULL ) {
|
||||
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
|
||||
"Failed to allocate Hotlist");
|
||||
return;
|
||||
}
|
||||
wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
|
||||
gemtk_wm_set_toolbar(hl.window, tree, 0, 0);
|
||||
gemtk_wm_unlink(hl.window);
|
||||
tree_hotlist_path = (const char*)&hl.path;
|
||||
hl.tv = atari_treeview_create(
|
||||
TREE_HOTLIST,
|
||||
hl.window,
|
||||
handle_event
|
||||
);
|
||||
if (hl.tv == NULL) {
|
||||
/* handle it properly, clean up previous allocs */
|
||||
LOG(("Failed to allocate treeview"));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
hl.init = true;
|
||||
}
|
||||
|
||||
|
||||
void atari_hotlist_open(void)
|
||||
{
|
||||
if( hl.init == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( hl.open == false ) {
|
||||
|
||||
GRECT pos;
|
||||
pos.g_x = desk_area.g_w - desk_area.g_w / 4;
|
||||
pos.g_y = desk_area.g_y;
|
||||
pos.g_w = desk_area.g_w / 4;
|
||||
pos.g_h = desk_area.g_h;
|
||||
|
||||
wind_open_grect(gemtk_wm_get_handle(hl.window), &pos);
|
||||
hl.open = true;
|
||||
atari_treeview_open( hl.tv );
|
||||
} else {
|
||||
wind_set(gemtk_wm_get_handle(hl.window), WF_TOP, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void atari_hotlist_close(void)
|
||||
{
|
||||
wind_close(gemtk_wm_get_handle(hl.window));
|
||||
hl.open = false;
|
||||
atari_treeview_close(hl.tv);
|
||||
}
|
||||
|
||||
void atari_hotlist_destroy(void)
|
||||
{
|
||||
|
||||
if( hl.init == false) {
|
||||
return;
|
||||
}
|
||||
if( hl.window != NULL ) {
|
||||
if (hl.open)
|
||||
atari_hotlist_close();
|
||||
wind_delete(gemtk_wm_get_handle(hl.window));
|
||||
gemtk_wm_remove(hl.window);
|
||||
hl.window = NULL;
|
||||
atari_treeview_destroy(hl.tv);
|
||||
hl.init = false;
|
||||
}
|
||||
LOG(("done"));
|
||||
}
|
||||
|
||||
void atari_hotlist_redraw(void)
|
||||
{
|
||||
int i = 01;
|
||||
atari_treeview_redraw(hl.tv);
|
||||
}
|
||||
|
||||
struct node;
|
||||
|
||||
void atari_hotlist_add_page( const char * url, const char * title )
|
||||
{
|
||||
struct node * root;
|
||||
struct node * selected = NULL;
|
||||
struct node * folder = NULL;
|
||||
nsurl *nsurl;
|
||||
NSTREEVIEW tv = hl.tv;
|
||||
if(hl.tv == NULL )
|
||||
return;
|
||||
|
||||
atari_hotlist_open();
|
||||
|
||||
if (nsurl_create(url, &nsurl) != NSERROR_OK)
|
||||
return;
|
||||
|
||||
if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){
|
||||
hotlist_add_entry( nsurl, title, true, hl.tv->click.y );
|
||||
} else {
|
||||
hotlist_add_url( nsurl );
|
||||
}
|
||||
nsurl_unref(nsurl);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_HOTLIST_H
|
||||
#define NS_ATARI_HOTLIST_H
|
||||
#include <stdbool.h>
|
||||
#include "desktop/tree.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/treeview.h"
|
||||
/* The hotlist window, toolbar and treeview data. */
|
||||
|
||||
struct atari_hotlist {
|
||||
GUIWIN * window;
|
||||
NSTREEVIEW tv; /*< The hotlist treeview handle. */
|
||||
bool open;
|
||||
bool init;
|
||||
char path[PATH_MAX];
|
||||
};
|
||||
|
||||
extern struct atari_hotlist hl;
|
||||
|
||||
void atari_hotlist_init( void );
|
||||
void atari_hotlist_open( void );
|
||||
void atari_hotlist_close( void );
|
||||
void atari_hotlist_destroy( void );
|
||||
void atari_hotlist_add_page( const char * url, const char * title );
|
||||
|
||||
void atari_hotlist_redraw( void );
|
||||
|
||||
|
||||
#endif
|
|
@ -36,10 +36,8 @@ void dump_font_drivers(void)
|
|||
{
|
||||
int i = 0;
|
||||
while( font_driver_table[i].name != NULL ) {
|
||||
printf("%s -> flags: %d\n",
|
||||
font_driver_table[i].name,
|
||||
font_driver_table[i].flags
|
||||
);
|
||||
printf("%s -> flags: %d\n", font_driver_table[i].name,
|
||||
font_driver_table[i].flags);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,375 @@
|
|||
/*
|
||||
* Copyright 2013 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/>.
|
||||
*
|
||||
* Module Description:
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/search.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/rootwin.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/search.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
|
||||
extern struct gui_window * input_window;
|
||||
extern void * h_gem_rsrc;
|
||||
extern GRECT desk_area;
|
||||
|
||||
|
||||
static SEARCH_FORM_SESSION current;
|
||||
static OBJECT *dlgtree;
|
||||
static GUIWIN *searchwin;
|
||||
static short h_aes_win;
|
||||
|
||||
static void nsatari_search_set_status(bool found, void *p);
|
||||
static void nsatari_search_set_hourglass(bool active, void *p);
|
||||
static void nsatari_search_add_recent(const char *string, void *p);
|
||||
void nsatari_search_set_forward_state(bool active, void *p);
|
||||
void nsatari_search_set_back_state(bool active, void *p);
|
||||
|
||||
static struct gui_search_callbacks nsatari_search_callbacks = {
|
||||
nsatari_search_set_forward_state,
|
||||
nsatari_search_set_back_state,
|
||||
nsatari_search_set_status,
|
||||
nsatari_search_set_hourglass,
|
||||
nsatari_search_add_recent
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Change the displayed search status.
|
||||
* \param found search pattern matched in text
|
||||
* \param p the pointer sent to search_verify_new() / search_create_context()
|
||||
*/
|
||||
|
||||
void nsatari_search_set_status(bool found, void *p)
|
||||
{
|
||||
LOG(("%p set status: %d\n", p, found));
|
||||
}
|
||||
|
||||
/**
|
||||
* display hourglass while searching
|
||||
* \param active start/stop indicator
|
||||
* \param p the pointer sent to search_verify_new() / search_create_context()
|
||||
*/
|
||||
|
||||
void nsatari_search_set_hourglass(bool active, void *p)
|
||||
{
|
||||
SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
|
||||
LOG((""));
|
||||
if (active && current != NULL)
|
||||
gui_window_set_pointer(s->bw->window, GUI_POINTER_PROGRESS);
|
||||
else
|
||||
gui_window_set_pointer(s->bw->window, GUI_POINTER_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* add search string to recent searches list
|
||||
* front is at liberty how to implement the bare notification
|
||||
* should normally store a strdup() of the string;
|
||||
* core gives no guarantee of the integrity of the const char *
|
||||
* \param string search pattern
|
||||
* \param p the pointer sent to search_verify_new() / search_create_context()
|
||||
*/
|
||||
|
||||
void nsatari_search_add_recent(const char *string, void *p)
|
||||
{
|
||||
LOG(("%p add recent: %s\n", p, string));
|
||||
}
|
||||
|
||||
/**
|
||||
* activate search forwards button in gui
|
||||
* \param active activate/inactivate
|
||||
* \param p the pointer sent to search_verify_new() / search_create_context()
|
||||
*/
|
||||
|
||||
void nsatari_search_set_forward_state(bool active, void *p)
|
||||
{
|
||||
SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
|
||||
/* deactivate back cb */
|
||||
LOG(("%p: set forward state: %d\n", p, active));
|
||||
}
|
||||
|
||||
/**
|
||||
* activate search back button in gui
|
||||
* \param active activate/inactivate
|
||||
* \param p the pointer sent to search_verify_new() / search_create_context()
|
||||
*/
|
||||
|
||||
void nsatari_search_set_back_state(bool active, void *p)
|
||||
{
|
||||
SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
|
||||
/* deactivate back cb */
|
||||
LOG(("%p: set back state: %d\n", p, active));
|
||||
}
|
||||
|
||||
/*
|
||||
void search_redraw(void *session, GRECT *clip)
|
||||
{
|
||||
GRECT area, clipped_area;
|
||||
struct gui_window *gw = input_window;
|
||||
short pxy[4];
|
||||
VdiHdl vh;
|
||||
|
||||
if(gw == NULL)
|
||||
return;
|
||||
|
||||
window_get_grect(gw->root, BROWSER_AREA_SEARCH, &area);
|
||||
|
||||
clipped_area = area;
|
||||
|
||||
if (!rc_intersect(clip, &clipped_area)) {
|
||||
return;
|
||||
}
|
||||
|
||||
OBJECT * tree = get_tree(SEARCH);
|
||||
tree->ob_x = area.g_x;
|
||||
tree->ob_y = area.g_y;
|
||||
tree->ob_width = area.g_w;
|
||||
tree->ob_height = area.g_h;
|
||||
|
||||
objc_draw_grect(tree, 0, 8, &clipped_area);
|
||||
}
|
||||
*/
|
||||
|
||||
static SEARCH_FORM_SESSION get_search_session(GUIWIN * win)
|
||||
{
|
||||
return (current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void set_text( short idx, char * text, int len )
|
||||
{
|
||||
char spare[255];
|
||||
|
||||
if( len > 254 )
|
||||
len = 254;
|
||||
if( text != NULL ){
|
||||
strncpy(spare, text, 254);
|
||||
} else {
|
||||
strcpy(spare, "");
|
||||
}
|
||||
|
||||
set_string(dlgtree, idx, spare);
|
||||
}
|
||||
|
||||
static void destroy_search_session(SEARCH_FORM_SESSION s)
|
||||
{
|
||||
if(s != NULL ){
|
||||
LOG((""));
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
|
||||
static int apply_form(GUIWIN *win, struct s_search_form_state * s)
|
||||
{
|
||||
OBJECT * obj = dlgtree;
|
||||
char * cstr;
|
||||
|
||||
if( obj == NULL ){
|
||||
goto error;
|
||||
}
|
||||
|
||||
s->flags = 0;
|
||||
if( (obj[SEARCH_CB_FWD].ob_state & OS_SELECTED) != 0 )
|
||||
s->flags = SEARCH_FLAG_FORWARDS;
|
||||
if( (obj[SEARCH_CB_CASESENSE].ob_state & OS_SELECTED) != 0 )
|
||||
s->flags |= SEARCH_FLAG_CASE_SENSITIVE;
|
||||
if( (obj[SEARCH_CB_SHOWALL].ob_state & OS_SELECTED) != 0 )
|
||||
s->flags |= SEARCH_FLAG_SHOWALL;
|
||||
|
||||
cstr = get_text(dlgtree, SEARCH_TB_SRCH);
|
||||
snprintf(s->text, 31, "%s", cstr);
|
||||
return ( 0 );
|
||||
|
||||
error:
|
||||
s->flags = SEARCH_FLAG_FORWARDS;
|
||||
strncpy((char*)&s->text[0], "", 31 );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* checks for search parameters changes */
|
||||
static bool form_changed(GUIWIN * w)
|
||||
{
|
||||
bool check;
|
||||
struct s_search_form_state cur;
|
||||
SEARCH_FORM_SESSION s = get_search_session(w);
|
||||
if( s == NULL )
|
||||
return false;
|
||||
OBJECT * obj = dlgtree;
|
||||
assert(s != NULL && obj != NULL);
|
||||
uint32_t flags_old = s->state.flags;
|
||||
apply_form(w, &cur);
|
||||
|
||||
/* adjust the forward flag, it should not init an new search */
|
||||
flags_old |= SEARCH_FLAG_FORWARDS;
|
||||
cur.flags |= SEARCH_FLAG_FORWARDS;
|
||||
if( cur.flags != flags_old ){
|
||||
return( true );
|
||||
}
|
||||
|
||||
char * cstr;
|
||||
cstr = get_text(obj, SEARCH_TB_SRCH);
|
||||
if (cstr != NULL){
|
||||
if (strcmp(cstr, (char*)&s->state.text) != 0) {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
||||
static void __CDECL evnt_bt_srch_click(GUIWIN * win, int index, int unused, void *unused2)
|
||||
{
|
||||
|
||||
bool fwd;
|
||||
SEARCH_FORM_SESSION s = get_search_session(searchwin);
|
||||
OBJECT * obj = dlgtree;
|
||||
search_flags_t flags = 0;
|
||||
|
||||
|
||||
if( form_changed(searchwin) ){
|
||||
browser_window_search_destroy_context(s->bw);
|
||||
apply_form(searchwin, &s->state);
|
||||
} else {
|
||||
/* get search direction manually: */
|
||||
if( (obj[SEARCH_CB_FWD].ob_state & OS_SELECTED) != 0 )
|
||||
s->state.flags |= SEARCH_FLAG_FORWARDS;
|
||||
else
|
||||
s->state.flags &= (~SEARCH_FLAG_FORWARDS);
|
||||
}
|
||||
if( browser_window_search_verify_new(s->bw, &nsatari_search_callbacks, s) ){
|
||||
browser_window_search_step(s->bw, s->state.flags, get_text(obj, SEARCH_TB_SRCH));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void __CDECL evnt_cb_click(GUIWIN *win, int index, int unused, void *unused2)
|
||||
{
|
||||
|
||||
short newstate;
|
||||
|
||||
}
|
||||
|
||||
static void __CDECL evnt_close(GUIWIN *win, short buff[8])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void search_destroy(struct gui_window *gw)
|
||||
{
|
||||
/* Free Search Contexts */
|
||||
/* todo: destroy search context, if any? */
|
||||
LOG((""));
|
||||
|
||||
if (current != NULL){
|
||||
destroy_search_session(current);
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
guiwin_remove(searchwin);
|
||||
searchwin = NULL;
|
||||
|
||||
wind_close(h_aes_win);
|
||||
wind_delete(h_aes_win);
|
||||
h_aes_win = -1;
|
||||
|
||||
LOG(("done"));
|
||||
}
|
||||
|
||||
SEARCH_FORM_SESSION open_browser_search(struct gui_window * gw)
|
||||
{
|
||||
char * title;
|
||||
SEARCH_FORM_SESSION sfs;
|
||||
GRECT pos, treesize;
|
||||
uint32_t kind = CLOSER | NAME | MOVER;
|
||||
|
||||
if (dlgtree == NULL) {
|
||||
dlgtree = get_tree(SEARCH);
|
||||
if (dlgtree == NULL) {
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
if(searchwin){
|
||||
search_destroy(gw);
|
||||
}
|
||||
|
||||
|
||||
sfs = calloc(1, sizeof(struct s_search_form_session));
|
||||
if( sfs == NULL )
|
||||
return( NULL );
|
||||
|
||||
title = (char*)messages_get("FindTextNS");
|
||||
if (title == NULL)
|
||||
title = (char*)"Find text ...";
|
||||
|
||||
/* setup dipslay position: right corner */
|
||||
treesize.g_x = 0;
|
||||
treesize.g_y = 0;
|
||||
treesize.g_w = dlgtree->ob_width;
|
||||
treesize.g_h = dlgtree->ob_height;
|
||||
wind_calc_grect(WC_BORDER, kind, &treesize, &pos);
|
||||
pos.g_x = desk_area.g_w - pos.g_w;
|
||||
pos.g_y = desk_area.g_h - pos.g_h;
|
||||
|
||||
/* create the dialog: */
|
||||
h_aes_win = wind_create_grect(kind, &pos);
|
||||
wind_set_str(h_aes_win, WF_NAME, title);
|
||||
|
||||
|
||||
current = sfs;
|
||||
sfs->bw = gw->browser->bw;
|
||||
/*
|
||||
sfs->formwind = mt_FormCreate( &app, tree, WAT_FORM,
|
||||
NULL, title,
|
||||
&pos, true, false);
|
||||
*/
|
||||
/*
|
||||
ObjcAttachFormFunc(sfs->formwind, SEARCH_BT_SEARCH, evnt_bt_srch_click,
|
||||
NULL);
|
||||
ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_CASESENSE, evnt_cb_click, NULL);
|
||||
ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_SHOWALL, evnt_cb_click, NULL);
|
||||
ObjcAttachFormFunc(sfs->formwind, SEARCH_CB_FWD, evnt_cb_click, NULL);
|
||||
EvntAdd(sfs->formwind, WM_CLOSED, evnt_close, EV_TOP);
|
||||
*/
|
||||
apply_form(searchwin, &sfs->state );
|
||||
set_text(SEARCH_TB_SRCH, (char*)"", 31);
|
||||
|
||||
return(current);
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2013 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/>.
|
||||
*
|
||||
* Module Description:
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NS_ATARI_SEARCH_H
|
||||
#define NS_ATARI_SEARCH_H
|
||||
|
||||
#define SEARCH_MAX_SLEN 24
|
||||
|
||||
struct gui_window;
|
||||
struct browser_window;
|
||||
|
||||
struct s_search_form_state
|
||||
{
|
||||
char text[32];
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
struct s_search_form_session {
|
||||
struct browser_window * bw;
|
||||
struct s_search_form_state state;
|
||||
};
|
||||
|
||||
|
||||
typedef struct s_search_form_session * SEARCH_FORM_SESSION;
|
||||
|
||||
SEARCH_FORM_SESSION open_browser_search(struct gui_window * gw);
|
||||
void search_destroy(struct gui_window * gw);
|
||||
|
||||
struct s_search_session
|
||||
|
||||
#endif
|
|
@ -1,455 +1,179 @@
|
|||
/*
|
||||
* 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/>.
|
||||
/*
|
||||
* Copyright 2013 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 <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include "assert.h"
|
||||
#include "cflib.h"
|
||||
|
||||
#include "utils/nsoption.h"
|
||||
#include "content/urldb.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/treeview.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/treeview.h"
|
||||
#include "atari/plot/plot.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
#include "cflib.h"
|
||||
|
||||
enum treeview_area_e {
|
||||
TREEVIEW_AREA_WORK = 0,
|
||||
TREEVIEW_AREA_TOOLBAR,
|
||||
TREEVIEW_AREA_CONTENT
|
||||
};
|
||||
|
||||
extern int mouse_hold_start[3];
|
||||
extern browser_mouse_state bmstate;
|
||||
extern short last_drag_x;
|
||||
extern short last_drag_y;
|
||||
extern long atari_plot_flags;
|
||||
extern int atari_plot_vdi_handle;
|
||||
|
||||
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 void atari_treeview_get_grect(NSTREEVIEW tree,
|
||||
enum treeview_area_e mode, GRECT *dest);
|
||||
|
||||
static const struct treeview_table atari_tree_callbacks = {
|
||||
atari_treeview_request_redraw,
|
||||
atari_treeview_resized,
|
||||
atari_treeview_scroll_visible,
|
||||
atari_treeview_get_dimensions
|
||||
};
|
||||
|
||||
static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
|
||||
short msg[8]);
|
||||
static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
|
||||
short msg[8]);
|
||||
static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
|
||||
short msg[8]);
|
||||
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
|
||||
NSTREEVIEW tv = (NSTREEVIEW) gemtk_wm_get_user_data(win);
|
||||
|
||||
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
|
||||
// handle message
|
||||
switch (msg[0]) {
|
||||
|
||||
case WM_REDRAW:
|
||||
on_redraw_event(tv, ev_out, msg);
|
||||
break;
|
||||
|
||||
case WM_SIZED:
|
||||
case WM_FULLED:
|
||||
//atari_treeview_resized(tv->tree, tv->extent.x, tv->extent.y, tv);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
|
||||
on_keybd_event(tv, ev_out, msg);
|
||||
}
|
||||
if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
|
||||
LOG(("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
|
||||
ev_out->emo_mouse.p_y));
|
||||
on_mbutton_event(tv, ev_out, msg);
|
||||
}
|
||||
|
||||
if(tv != NULL && tv->user_func != NULL){
|
||||
tv->user_func(win, ev_out, msg);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
|
||||
short msg[8])
|
||||
{
|
||||
bool r=false;
|
||||
long kstate = 0;
|
||||
long kcode = 0;
|
||||
long ucs4;
|
||||
long ik;
|
||||
unsigned short nkc = 0;
|
||||
unsigned short nks = 0;
|
||||
unsigned char ascii;
|
||||
|
||||
kstate = ev_out->emo_kmeta;
|
||||
kcode = ev_out->emo_kreturn;
|
||||
nkc= gem_to_norm( (short)kstate, (short)kcode );
|
||||
ascii = (nkc & 0xFF);
|
||||
ik = nkc_to_input_key( nkc, &ucs4 );
|
||||
|
||||
if( ik == 0 ){
|
||||
if (ascii >= 9 ) {
|
||||
r = tree_keypress( tv->tree, ucs4 );
|
||||
}
|
||||
} else {
|
||||
r = tree_keypress( tv->tree, ik );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
|
||||
short msg[8])
|
||||
{
|
||||
GRECT work, clip;
|
||||
struct gemtk_wm_scroll_info_s *slid;
|
||||
|
||||
if( tv == NULL )
|
||||
return;
|
||||
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
|
||||
slid = gemtk_wm_get_scroll_info(tv->window);
|
||||
|
||||
clip = work;
|
||||
if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
|
||||
clip.g_x -= work.g_x;
|
||||
clip.g_y -= work.g_y;
|
||||
if( clip.g_x < 0 ) {
|
||||
clip.g_w = work.g_w + clip.g_x;
|
||||
clip.g_x = 0;
|
||||
}
|
||||
if( clip.g_y < 0 ) {
|
||||
clip.g_h = work.g_h + clip.g_y;
|
||||
clip.g_y = 0;
|
||||
}
|
||||
if( clip.g_h > 0 && clip.g_w > 0 ) {
|
||||
// TODO: get slider values
|
||||
atari_treeview_request_redraw((slid->x_pos*slid->x_unit_px) + clip.g_x,
|
||||
(slid->y_pos*slid->y_unit_px) + clip.g_y,
|
||||
clip.g_w, clip.g_h, tv
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
|
||||
short msg[8])
|
||||
{
|
||||
struct gemtk_wm_scroll_info_s *slid;
|
||||
GRECT work;
|
||||
short mx, my;
|
||||
|
||||
if(tv == NULL)
|
||||
return;
|
||||
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
|
||||
slid = gemtk_wm_get_scroll_info(tv->window);
|
||||
mx = ev_out->emo_mouse.p_x;
|
||||
my = ev_out->emo_mouse.p_y;
|
||||
|
||||
/* mouse click relative origin: */
|
||||
|
||||
short origin_rel_x = (mx-work.g_x) +
|
||||
(slid->x_pos*slid->x_unit_px);
|
||||
short origin_rel_y = (my-work.g_y) +
|
||||
(slid->y_pos*slid->y_unit_px);
|
||||
|
||||
if( origin_rel_x >= 0 && origin_rel_y >= 0
|
||||
&& mx < work.g_x + work.g_w
|
||||
&& my < work.g_y + work.g_h )
|
||||
{
|
||||
int bms;
|
||||
bool ignore=false;
|
||||
short cur_rel_x, cur_rel_y, dummy, mbut;
|
||||
|
||||
if (ev_out->emo_mclicks == 2) {
|
||||
tree_mouse_action(tv->tree,
|
||||
BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK,
|
||||
origin_rel_x, origin_rel_y );
|
||||
return;
|
||||
}
|
||||
|
||||
graf_mkstate(&cur_rel_x, &cur_rel_x, &mbut, &dummy);
|
||||
if( (mbut&1) == 0 ){
|
||||
bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1;
|
||||
if(ev_out->emo_mclicks == 2 ) {
|
||||
bms = BROWSER_MOUSE_DOUBLE_CLICK;
|
||||
}
|
||||
tree_mouse_action(tv->tree, bms, origin_rel_x, origin_rel_y );
|
||||
} else {
|
||||
/* button still pressed */
|
||||
|
||||
short prev_x = origin_rel_x;
|
||||
short prev_y = origin_rel_y;
|
||||
|
||||
cur_rel_x = origin_rel_x;
|
||||
cur_rel_y = origin_rel_y;
|
||||
|
||||
gem_set_cursor(&gem_cursors.hand);
|
||||
|
||||
tv->startdrag.x = origin_rel_x;
|
||||
tv->startdrag.y = origin_rel_y;
|
||||
|
||||
tree_mouse_action( tv->tree,
|
||||
BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON ,
|
||||
cur_rel_x, cur_rel_y );
|
||||
do{
|
||||
if( abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5 ){
|
||||
tree_mouse_action( tv->tree,
|
||||
BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON,
|
||||
cur_rel_x, cur_rel_y);
|
||||
prev_x = cur_rel_x;
|
||||
prev_y = cur_rel_y;
|
||||
}
|
||||
|
||||
if( tv->redraw )
|
||||
atari_treeview_redraw( tv );
|
||||
/* sample mouse button state: */
|
||||
graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
|
||||
cur_rel_x = (cur_rel_x-work.g_x)+(slid->x_pos*slid->x_unit_px);
|
||||
cur_rel_y = (cur_rel_y-work.g_y)+(slid->y_pos*slid->y_unit_px);
|
||||
} while( mbut & 1 );
|
||||
|
||||
tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
|
||||
cur_rel_x, cur_rel_y );
|
||||
gem_set_cursor(&gem_cursors.arrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSTREEVIEW atari_treeview_create(uint32_t flags, GUIWIN *win,
|
||||
gemtk_wm_event_handler_f user_func)
|
||||
{
|
||||
struct gemtk_wm_scroll_info_s *slid;
|
||||
NSTREEVIEW new;
|
||||
|
||||
if( win == NULL )
|
||||
return( NULL );
|
||||
|
||||
new = malloc(sizeof(struct atari_treeview));
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(new, 0, sizeof(struct atari_treeview));
|
||||
|
||||
/* Store the window ref inside the new treeview: */
|
||||
new->window = win;
|
||||
new->user_func = user_func;
|
||||
|
||||
// Setup gemtk event handler function and set the userdata
|
||||
// to be the new treeview:
|
||||
gemtk_wm_set_event_handler(win, handle_event);
|
||||
gemtk_wm_set_user_data(win, (void*)new);
|
||||
|
||||
// Get acces to the gemtk scroll info struct:
|
||||
slid = gemtk_wm_get_scroll_info(new->window);
|
||||
|
||||
// Setup line and column height/width of the window,
|
||||
// each scroll takes the configured steps:
|
||||
slid->y_unit_px = 16;
|
||||
slid->x_unit_px = 16;
|
||||
|
||||
// now create a new netsurf tree:
|
||||
new->tree = tree_create(flags, &atari_tree_callbacks, new);
|
||||
if (new->tree == NULL) {
|
||||
free(new);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return(new);
|
||||
}
|
||||
|
||||
void atari_treeview_open( NSTREEVIEW tv )
|
||||
{
|
||||
if( tv->window != NULL ) {
|
||||
gemtk_wm_link(tv->window);
|
||||
}
|
||||
}
|
||||
|
||||
void atari_treeview_close(NSTREEVIEW tv)
|
||||
{
|
||||
if(tv->window != NULL) {
|
||||
gemtk_wm_unlink(tv->window);
|
||||
}
|
||||
}
|
||||
|
||||
void atari_treeview_destroy( NSTREEVIEW tv )
|
||||
{
|
||||
if( tv != NULL ){
|
||||
tv->disposing = true;
|
||||
LOG(("tree: %p", tv));
|
||||
if( tv->tree != NULL ) {
|
||||
tree_delete(tv->tree);
|
||||
tv->tree = NULL;
|
||||
}
|
||||
free( tv );
|
||||
}
|
||||
}
|
||||
|
||||
bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
|
||||
{
|
||||
GRECT work;
|
||||
struct gemtk_wm_scroll_info_s *slid;
|
||||
|
||||
if( tv == NULL )
|
||||
return ( false );
|
||||
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
|
||||
slid = gemtk_wm_get_scroll_info(tv->window);
|
||||
|
||||
int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
|
||||
int ry = (y-work.g_y)+(slid->y_pos*slid->y_unit_px);
|
||||
|
||||
tree_mouse_action(tv->tree, bms, rx, ry);
|
||||
|
||||
tv->click.x = rx;
|
||||
tv->click.y = ry;
|
||||
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void atari_treeview_redraw(NSTREEVIEW tv)
|
||||
{
|
||||
if (tv != NULL) {
|
||||
if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
|
||||
|
||||
short todo[4];
|
||||
GRECT work;
|
||||
short handle = gemtk_wm_get_handle(tv->window);
|
||||
struct gemtk_wm_scroll_info_s *slid;
|
||||
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work);
|
||||
slid = gemtk_wm_get_scroll_info(tv->window);
|
||||
|
||||
struct redraw_context ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &atari_plotters
|
||||
};
|
||||
plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
|
||||
if (plot_lock() == false)
|
||||
return;
|
||||
|
||||
if( wind_get(handle, WF_FIRSTXYWH,
|
||||
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
|
||||
while (todo[2] && todo[3]) {
|
||||
|
||||
short pxy[4];
|
||||
pxy[0] = todo[0];
|
||||
pxy[1] = todo[1];
|
||||
pxy[2] = todo[0] + todo[2]-1;
|
||||
pxy[3] = todo[1] + todo[3]-1;
|
||||
vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy);
|
||||
|
||||
/* convert screen to treeview coords: */
|
||||
todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
|
||||
todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
|
||||
if( todo[0] < 0 ){
|
||||
todo[2] = todo[2] + todo[0];
|
||||
todo[0] = 0;
|
||||
}
|
||||
if( todo[1] < 0 ){
|
||||
todo[3] = todo[3] + todo[1];
|
||||
todo[1] = 0;
|
||||
}
|
||||
|
||||
// TODO: get slider values
|
||||
if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
|
||||
tree_draw(tv->tree, -(slid->x_pos*slid->x_unit_px),
|
||||
-(slid->y_pos*slid->y_unit_px),
|
||||
todo[0], todo[1], todo[2], todo[3], &ctx
|
||||
);
|
||||
}
|
||||
vs_clip(atari_plot_vdi_handle, 0, (short*)&pxy);
|
||||
if (wind_get(handle, WF_NEXTXYWH,
|
||||
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plot_unlock();
|
||||
return;
|
||||
}
|
||||
plot_unlock();
|
||||
tv->redraw = false;
|
||||
tv->rdw_area.g_x = 65000;
|
||||
tv->rdw_area.g_y = 65000;
|
||||
tv->rdw_area.g_w = -1;
|
||||
tv->rdw_area.g_h = -1;
|
||||
} else {
|
||||
/* just copy stuff from the offscreen buffer */
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "atari/treeview.h"
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Declare Core Window Callbacks:
|
||||
*/
|
||||
void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
|
||||
|
||||
void atari_treeview_redraw_request(struct core_window *cw,
|
||||
const struct rect *r);
|
||||
void atari_treeview_update_size(struct core_window *cw, int width, int height);
|
||||
void atari_treeview_scroll_visible(struct core_window *cw,
|
||||
const struct rect *r);
|
||||
void atari_treeview_get_window_dimensions(struct core_window *cw,
|
||||
int *width, int *height);
|
||||
void atari_treeview_drag_status(struct core_window *cw,
|
||||
core_window_drag_status ds);
|
||||
|
||||
|
||||
static struct core_window_callback_table cw_t = {
|
||||
.redraw_request = atari_treeview_redraw_request,
|
||||
.update_size = atari_treeview_update_size,
|
||||
.scroll_visible = atari_treeview_scroll_visible,
|
||||
.get_window_dimensions = atari_treeview_get_window_dimensions,
|
||||
.drag_status = atari_treeview_drag_status
|
||||
};
|
||||
|
||||
|
||||
struct atari_treeview_window {
|
||||
GUIWIN * window;
|
||||
bool disposing;
|
||||
bool redraw;
|
||||
GRECT rdw_area;
|
||||
POINT extent;
|
||||
POINT click;
|
||||
POINT startdrag;
|
||||
struct atari_treeview_callbacks *io;
|
||||
};
|
||||
|
||||
typedef struct atari_treeview_window *ATARI_TREEVIEW;
|
||||
|
||||
|
||||
/* native GUI event handlers: */
|
||||
static void __CDECL on_mbutton_event(struct atari_treeview_window tvw,
|
||||
EVMULT_OUT *ev_out, short msg[8]);
|
||||
static void __CDECL on_keybd_event(struct atari_treeview_window tvw,
|
||||
EVMULT_OUT *ev_out, short msg[8]);
|
||||
static void __CDECL on_redraw_event(struct atari_treeview_window tvw,
|
||||
EVMULT_OUT *ev_out, short msg[8]);
|
||||
|
||||
/* GEMTK event sink: */
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
if ( pw != NULL ) {
|
||||
NSTREEVIEW tv = (NSTREEVIEW) pw;
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct atari_treeview_window *
|
||||
atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks,
|
||||
uint32_t flags)
|
||||
{
|
||||
/*
|
||||
init_func();
|
||||
|
||||
sslcert_viewer_init(&cw_t, (struct core_window *)tree,
|
||||
ssl_current_session);
|
||||
*/
|
||||
|
||||
/* allocate the core_window struct: */
|
||||
struct atari_treeview_window * cw;
|
||||
|
||||
cw = calloc(sizeof(struct atari_treeview_window), 1);
|
||||
if (cw == NULL) {
|
||||
LOG(("calloc failed"));
|
||||
warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cw->window = win;
|
||||
cw->io = callbacks;
|
||||
|
||||
assert(cw->io);
|
||||
assert(cw->io->init);
|
||||
|
||||
nserror err = cw->io->init(cw, &cw_t);
|
||||
if (err != NSERROR_OK) {
|
||||
free(cw);
|
||||
cw = NULL;
|
||||
}
|
||||
|
||||
return(cw);
|
||||
}
|
||||
|
||||
void atari_treeview_delete(struct atari_treeview_window * cw)
|
||||
{
|
||||
assert(cw);
|
||||
assert(cw->io->fini);
|
||||
|
||||
cw->io->fini(cw);
|
||||
|
||||
free(cw);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Core Window Callbacks:
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Request a redraw of the window
|
||||
*
|
||||
* \param cw the core window object
|
||||
* \param r rectangle to redraw
|
||||
*/
|
||||
void atari_treeview_redraw_request(struct core_window *cw, const struct rect *r)
|
||||
{
|
||||
GRECT area;
|
||||
|
||||
RECT_TO_GRECT(r, &area)
|
||||
|
||||
if (cw != NULL) {
|
||||
ATARI_TREEVIEW tv = (ATARI_TREEVIEW) cw;
|
||||
if( tv->redraw == false ){
|
||||
tv->redraw = true;
|
||||
tv->rdw_area.g_x = x;
|
||||
tv->rdw_area.g_y = y;
|
||||
tv->rdw_area.g_w = w;
|
||||
tv->rdw_area.g_h = h;
|
||||
tv->rdw_area.g_x = area.g_x;
|
||||
tv->rdw_area.g_y = area.g_y;
|
||||
tv->rdw_area.g_w = area.g_w;
|
||||
tv->rdw_area.g_h = area.g_h;
|
||||
} else {
|
||||
/* merge the redraw area to the new area.: */
|
||||
int newx1 = x+w;
|
||||
int newy1 = y+h;
|
||||
int newx1 = area.g_x+area.g_w;
|
||||
int newy1 = area.g_y+area.g_h;
|
||||
int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
|
||||
int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
|
||||
tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, x);
|
||||
tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, y);
|
||||
tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, area.g_x);
|
||||
tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, area.g_y);
|
||||
tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
|
||||
tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
|
||||
}
|
||||
|
@ -457,89 +181,54 @@ void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback to notify us of a new overall tree size.
|
||||
* Update the limits of the window
|
||||
*
|
||||
* \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.
|
||||
* \param cw the core window object
|
||||
* \param width the width in px, or negative if don't care
|
||||
* \param height the height in px, or negative if don't care
|
||||
*/
|
||||
|
||||
void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
|
||||
void atari_treeview_update_size(struct core_window *cw, int width, int height)
|
||||
{
|
||||
GRECT area;
|
||||
if (pw != NULL) {
|
||||
NSTREEVIEW tv = (NSTREEVIEW) pw;
|
||||
if( tv->disposing )
|
||||
return;
|
||||
|
||||
tv->extent.x = width;
|
||||
tv->extent.y = height;
|
||||
|
||||
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(tv->window);
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &area);
|
||||
|
||||
if(width > -1) {
|
||||
slid->x_units = (width/slid->x_unit_px);
|
||||
gemtk_wm_update_slider(tv->window, GEMTK_WM_HSLIDER);
|
||||
}
|
||||
|
||||
if(height > -1){
|
||||
slid->y_units = (height/slid->y_unit_px);
|
||||
gemtk_wm_update_slider(tv->window, GEMTK_WM_VSLIDER);
|
||||
}
|
||||
|
||||
/*printf("units content: %d, units viewport: %d\n", (height/slid->y_unit_px),
|
||||
(area.g_h/slid->y_unit_px));*/
|
||||
//gemtk_wm_update_slider(tv->window, GEMTK_WM_VH_SLIDER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback to request that a section of the tree is scrolled into view.
|
||||
* Scroll the window to make area visible
|
||||
*
|
||||
* \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.
|
||||
* \param cw the core window object
|
||||
* \param r rectangle to make visible
|
||||
*/
|
||||
|
||||
void atari_treeview_scroll_visible(int y, int height, void *pw)
|
||||
{
|
||||
/* we don't support dragging outside the treeview */
|
||||
/* so we don't need to implement this? */
|
||||
}
|
||||
|
||||
static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
|
||||
GRECT *dest)
|
||||
void atari_treeview_scroll_visible(struct core_window *cw, const struct rect *r)
|
||||
{
|
||||
|
||||
if (mode == TREEVIEW_AREA_CONTENT) {
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, dest);
|
||||
}
|
||||
else if (mode == TREEVIEW_AREA_TOOLBAR) {
|
||||
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback to return the tree window dimensions to the treeview system.
|
||||
* Get window viewport dimensions
|
||||
*
|
||||
* \param *width Return the window width.
|
||||
* \param *height Return the window height.
|
||||
* \param *pw The treeview object to use.
|
||||
* \param cw the core window object
|
||||
* \param width to be set to viewport width in px, if non NULL
|
||||
* \param height to be set to viewport height in px, if non NULL
|
||||
*/
|
||||
|
||||
void atari_treeview_get_dimensions(int *width, int *height,
|
||||
void *pw)
|
||||
void atari_treeview_get_window_dimensions(struct core_window *cw,
|
||||
int *width, int *height)
|
||||
{
|
||||
if (pw != NULL && (width != NULL || height != NULL)) {
|
||||
NSTREEVIEW tv = (NSTREEVIEW) pw;
|
||||
GRECT work;
|
||||
atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
|
||||
*width = work.g_w;
|
||||
*height = work.g_h;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inform corewindow owner of drag status
|
||||
*
|
||||
* \param cw the core window object
|
||||
* \param ds the current drag status
|
||||
*/
|
||||
void atari_treeview_drag_status(struct core_window *cw,
|
||||
core_window_drag_status ds)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,55 +1,41 @@
|
|||
/*
|
||||
* 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/>.
|
||||
/*
|
||||
* Copyright 2013 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_TREEVIEW_H
|
||||
#define NS_ATARI_TREEVIEW_H
|
||||
#ifndef NSATARI_TREEVIEW_H
|
||||
#define NSATARI_TREEVIEW_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "desktop/tree.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/gemtk/gemtk.h"
|
||||
|
||||
#define ATARI_TREEVIEW_WIDGETS (CLOSER | MOVER | SIZER| NAME | FULLER | SMALLER | VSLIDE | HSLIDE | UPARROW | DNARROW | LFARROW | RTARROW)
|
||||
|
||||
struct atari_treeview
|
||||
{
|
||||
struct tree * tree;
|
||||
GUIWIN * window;
|
||||
bool disposing;
|
||||
bool redraw;
|
||||
GRECT rdw_area;
|
||||
POINT extent;
|
||||
POINT click;
|
||||
POINT startdrag;
|
||||
gemtk_wm_event_handler_f user_func;
|
||||
struct atari_treeview_callbacks {
|
||||
nserror (*init)(struct core_window *cw,
|
||||
struct core_window_callback_table * default_callbacks);
|
||||
void (*fini)(struct core_window *cw);
|
||||
void (*draw)(struct core_window *cw);
|
||||
void (*keypress)(struct core_window *cw);
|
||||
void (*mouse)(struct core_window *cw);
|
||||
gemtk_wm_event_handler_f gemtk_user_func;
|
||||
};
|
||||
|
||||
typedef struct atari_treeview * NSTREEVIEW;
|
||||
struct atari_treeview_callbacks;
|
||||
struct atari_treeview_window;
|
||||
|
||||
NSTREEVIEW atari_treeview_create( uint32_t flags, GUIWIN *win,
|
||||
gemtk_wm_event_handler_f user_func);
|
||||
void atari_treeview_destroy( NSTREEVIEW tv );
|
||||
void atari_treeview_open( NSTREEVIEW tv );
|
||||
void atari_treeview_close( NSTREEVIEW tv );
|
||||
void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw);
|
||||
void atari_treeview_redraw( NSTREEVIEW tv );
|
||||
bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y);
|
||||
struct atari_treeview_window *
|
||||
atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks,
|
||||
uint32_t flags);
|
||||
void atari_treeview_delete(struct atari_treeview_window * cw);
|
||||
|
||||
#endif //NSATARI_TREEVIEW_H
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue