summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-12-31 03:37:43 +0100
committerOle Loots <ole@monochrom.net>2012-12-31 03:37:43 +0100
commit695f0522370e43c5c6aa6b35a1c7c0ff93e5faa9 (patch)
tree4a95965fa12b7e5d2029e6a36e22774c2892b7d5 /atari
parentf0f57e34314b1a2e3327ab0ae65ec840efa3ee3a (diff)
downloadnetsurf-695f0522370e43c5c6aa6b35a1c7c0ff93e5faa9.tar.gz
netsurf-695f0522370e43c5c6aa6b35a1c7c0ff93e5faa9.tar.bz2
Moved form handling into gemtk,
removed several windom includes
Diffstat (limited to 'atari')
-rwxr-xr-xatari/bitmap.c1
-rw-r--r--atari/clipboard.c79
-rwxr-xr-xatari/clipboard.h6
-rw-r--r--atari/ctxmenu.c5
-rw-r--r--atari/deskmenu.c1
-rwxr-xr-xatari/download.c8
-rw-r--r--atari/encoding.h1
-rwxr-xr-xatari/findfile.c1
-rwxr-xr-xatari/font.c1
-rw-r--r--atari/gemtk/gemtk.h38
-rw-r--r--atari/gemtk/guiwin.c433
-rw-r--r--atari/gemtk/objc.c58
-rw-r--r--atari/gemtk/objc.h7
-rw-r--r--atari/gemtk/utils.c5
-rwxr-xr-xatari/gui.c7
-rwxr-xr-xatari/history.h1
-rwxr-xr-xatari/hotlist.h1
-rw-r--r--atari/search.c149
-rw-r--r--atari/search.h13
-rw-r--r--atari/settings.c221
-rw-r--r--atari/settings.h1
-rwxr-xr-xatari/statusbar.c1
-rw-r--r--atari/toolbar.c6
-rwxr-xr-xatari/treeview.h1
24 files changed, 652 insertions, 393 deletions
diff --git a/atari/bitmap.c b/atari/bitmap.c
index 1b5611fde..c01fa4d54 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -19,7 +19,6 @@
#include <inttypes.h>
#include <sys/types.h>
#include <string.h>
-#include <windom.h>
#include "assert.h"
diff --git a/atari/clipboard.c b/atari/clipboard.c
new file mode 100644
index 000000000..9b45e73cd
--- /dev/null
+++ b/atari/clipboard.c
@@ -0,0 +1,79 @@
+/*
+ * 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 <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <mint/osbind.h>
+#include "atari/clipboard.h"
+
+
+static int filesize(char * path)
+{
+ FILE *f;
+ int fs;
+
+ f = fopen( path, "r+b");
+ if(!f)
+ return(-1);
+
+ fseek(f, 0L, SEEK_END);
+ fs = ftell(f);
+ fclose(f);
+
+ return(fs);
+}
+
+int scrap_txt_write(char *str)
+{
+ scrap_wtxt(str);
+}
+
+char *scrap_txt_read(void)
+{
+ char * buf = NULL;
+ char path[80];
+ int file;
+ int len;
+
+ if (get_scrapdir (path))
+ {
+ strcat (path, "scrap.txt");
+ len = filesize(path);
+ if(len > 0){
+ if ((file = (int) Fopen (path, 0)) >= 0)
+ {
+ buf = malloc(len);
+ if(buf){
+ len = Fread (file, len, buf);
+ Fclose (file);
+ buf[len] = '\0';
+ return buf;
+ }
+ }
+ }
+ }
+
+}
+
diff --git a/atari/clipboard.h b/atari/clipboard.h
index aa032b7fd..f35161e13 100755
--- a/atari/clipboard.h
+++ b/atari/clipboard.h
@@ -18,10 +18,8 @@
#ifndef NS_ATARI_CLIPBOARD_H
#define NS_ATARI_CLIPBOARD_H
-
-#include <windom.h>
-int scrap_txt_write( APPvar app, char *str);
-char *scrap_txt_read( APPvar app );
+int scrap_txt_write(char *str);
+char *scrap_txt_read(void);
#endif
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index c9189af22..035fbcc9f 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -208,14 +208,15 @@ void context_popup(struct gui_window * gw, short x, short y)
case POP_CTX_COPY_URL:
if( (ctx->flags & CNT_IMG) && (ctx->ccdata.object != NULL) ){
if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ){
- scrap_txt_write(&app, (char*)nsurl_access(hlcache_handle_get_url(ctx->ccdata.object)) );
+ scrap_txt_write((char*)nsurl_access(
+ hlcache_handle_get_url(ctx->ccdata.object)));
}
}
break;
case POP_CTX_COPY_LINK:
if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL ){
- scrap_txt_write(&app, (char*)ctx->ccdata.link_url);
+ scrap_txt_write((char*)ctx->ccdata.link_url);
}
break;
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index 601ba9931..4a6b08318 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -1,5 +1,4 @@
#include <stdlib.h>
-#include <windom.h>
#include "utils/log.h"
#include "utils/messages.h"
diff --git a/atari/download.c b/atari/download.c
index bf3105f5b..c01ac805f 100755
--- a/atari/download.c
+++ b/atari/download.c
@@ -131,10 +131,10 @@ static void on_redraw(struct gui_download_window *dw, GRECT *clip)
/*
Update the AES Object to reflect current state of download:
*/
- ((TEDINFO *)get_obspec(tree, DOWNLOAD_FILENAME))->te_ptext = &dw->lbl_file;
- ((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_BYTES))->te_ptext = &dw->lbl_done;
- ((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_PERCENT))->te_ptext = &dw->lbl_percent;
- ((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_SPEED))->te_ptext = &dw->lbl_speed;
+ ((TEDINFO *)get_obspec(tree, DOWNLOAD_FILENAME))->te_ptext = dw->lbl_file;
+ ((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_BYTES))->te_ptext = dw->lbl_done;
+ ((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_PERCENT))->te_ptext = dw->lbl_percent;
+ ((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_SPEED))->te_ptext = dw->lbl_speed;
if (dw->size_total > 0 ) {
p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
diff --git a/atari/encoding.h b/atari/encoding.h
index 7b9cc8291..c85bac9fc 100644
--- a/atari/encoding.h
+++ b/atari/encoding.h
@@ -22,7 +22,6 @@
#include <inttypes.h>
#include <assert.h>
#include <stdbool.h>
-#include <windom.h>
#include "css/css.h"
#include "render/font.h"
diff --git a/atari/findfile.c b/atari/findfile.c
index 00502c9e6..d4c4c308d 100755
--- a/atari/findfile.c
+++ b/atari/findfile.c
@@ -24,7 +24,6 @@
#include <string.h>
#include <assert.h>
#include <curl/curl.h>
-#include <windom.h>
#include "utils/log.h"
#include "utils/url.h"
diff --git a/atari/font.c b/atari/font.c
index afb12092a..dfa0efee5 100755
--- a/atari/font.c
+++ b/atari/font.c
@@ -37,7 +37,6 @@
*/
#include <stdbool.h>
-#include <windom.h>
#include "css/css.h"
#include "render/font.h"
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index c77b0d958..b70ec0621 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -1,14 +1,18 @@
#ifndef GEMTK_H_INCLUDED
#define GEMTK_H_INCLUDED
-#include <gem.h>
-#include <mint/osbind.h>
-#include <mint/cookie.h>
#include <stdint.h>
#include <stdbool.h>
+#include <mint/osbind.h>
+#include <mint/cookie.h>
+
+#include <gem.h>
+#include <cflib.h>
+
+
/* -------------------------------------------------------------------------- */
-/* Utils */
+/* SYSTEM UTILS */
/* -------------------------------------------------------------------------- */
/* System type detection added by [GS] */
@@ -28,7 +32,6 @@
extern unsigned short _systype_v;
unsigned short _systype (void);
-OBJECT *get_tree( int idx );
#ifndef POINT_WITHIN
# define POINT_WITHIN(_x,_y, r) ((_x >= r.g_x) && (_x <= r.g_x + r.g_w ) \
@@ -95,11 +98,23 @@ short msg_box_show(short type, const char * msg);
#define GW_STATUS_SHADED 0x02
#define GW_XTYPE_CHECKBOX (101 << 8)
+#define GW_CB_SELECTED (OS_SELECTED | OS_CROSSED)
#define GUIWIN_VSLIDER 0x01
#define GUIWIN_HSLIDER 0x02
#define GUIWIN_VH_SLIDER 0x03
+/*
+ Message sent to the client application when an AES object is
+ clicked in an window which contains an form.
+
+ Message Parameters:
+ msg[4] = Clicked Object.
+ msg[5] = Number of clicks.
+ msg[6] = Modifier keys.
+*/
+#define GUIWIN_WM_FORM 1001
+
struct gui_window_s;
typedef struct gui_window_s GUIWIN;
typedef short (*guiwin_event_handler_f)(GUIWIN *gw,
@@ -139,6 +154,7 @@ void *guiwin_get_user_data(GUIWIN *win);
struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
void guiwin_set_scroll_grid(GUIWIN * win, short x, short y);
void guiwin_set_content_units(GUIWIN * win, short x, short y);
+void guiwin_set_form(GUIWIN *win, OBJECT *tree, short index);
bool guiwin_update_slider(GUIWIN *win, short mode);
void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh);
void guiwin_send_msg(GUIWIN *win, short msgtype, short a, short b, short c,
@@ -147,14 +163,22 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip);
+void guiwin_form_redraw(GUIWIN *gw, GRECT *clip);
void guiwin_clear(GUIWIN *win);
/* -------------------------------------------------------------------------- */
-/* AES Scroller module */
+/* AES SCROLLER MODULE */
+/* -------------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------------- */
+/* AES TABS MODULE */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
-/* AES Tabs module */
+/* AES OBJECT TREE TOOLS */
/* -------------------------------------------------------------------------- */
+GRECT * obj_screen_rect(OBJECT * tree, short obj);
+bool obj_is_inside(OBJECT * tree, short obj, GRECT *area);
+OBJECT *get_tree(int idx);
#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index a471fc92d..f0bb7445d 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -26,16 +26,21 @@
#include <mt_gem.h>
#include "gemtk.h"
-//#define DEBUG_PRINT(x) printf x
-#define DEBUG_PRINT(x)
+#define DEBUG_PRINT(x) printf x
+//#define DEBUG_PRINT(x)
struct gui_window_s {
short handle;
guiwin_event_handler_f handler_func;
uint32_t flags;
uint32_t state;
- OBJECT * toolbar;
+ OBJECT *toolbar;
+ short toolbar_edit_obj;
short toolbar_idx;
+ OBJECT *form;
+ short form_edit_obj;
+ short form_focus_obj;
+ short form_idx;
struct guiwin_scroll_info_s scroll_info;
void *user_data;
struct gui_window_s *next, *prev;
@@ -73,6 +78,10 @@ static void move_rect(GUIWIN * win, GRECT *rect, int dx, int dy)
wind_update(END_UPDATE);
}
+/**
+* Handles common events.
+* returns 0 when the event was not handled, 1 otherwise.
+*/
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, g_ro, g2;
@@ -90,8 +99,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
if(val != slid->x_pos) {
if (val < slid->x_pos) {
val = -(MAX(0, slid->x_pos-val));
- }
- else {
+ } else {
val = val-slid->x_pos;
}
guiwin_scroll(gw, GUIWIN_HSLIDER, val, false);
@@ -106,8 +114,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
if(val != slid->y_pos) {
if (val < slid->y_pos) {
val = -(slid->y_pos - val);
- }
- else {
+ } else {
val = val -slid->y_pos;
}
guiwin_scroll(gw, GUIWIN_VSLIDER, val, false);
@@ -126,7 +133,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WA_UPPAGE:
/* scroll page up */
guiwin_scroll(gw, GUIWIN_VSLIDER, -(g.g_h/slid->y_unit_px),
- true);
+ true);
break;
case WA_UPLINE:
@@ -137,7 +144,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WA_DNPAGE:
/* scroll page down */
guiwin_scroll(gw, GUIWIN_VSLIDER, g.g_h/slid->y_unit_px,
- true);
+ true);
break;
case WA_DNLINE:
@@ -148,25 +155,25 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WA_LFPAGE:
/* scroll page left */
guiwin_scroll(gw, GUIWIN_HSLIDER, -(g.g_w/slid->x_unit_px),
- true);
+ true);
break;
case WA_LFLINE:
/* scroll line left */
guiwin_scroll(gw, GUIWIN_HSLIDER, -1,
- true);
+ true);
break;
case WA_RTPAGE:
/* scroll page right */
guiwin_scroll(gw, GUIWIN_HSLIDER, (g.g_w/slid->x_unit_px),
- true);
+ true);
break;
case WA_RTLINE:
/* scroll line right */
guiwin_scroll(gw, GUIWIN_HSLIDER, 1,
- true);
+ true);
break;
default:
@@ -182,21 +189,34 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WM_MOVED:
wind_get_grect(gw->handle, WF_CURRXYWH, &g);
wind_set(gw->handle, WF_CURRXYWH, msg[4], msg[5], g.g_w, g.g_h);
+
+ if (gw->form) {
+
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
+ slid = guiwin_get_scroll_info(gw);
+
+ gw->form[gw->form_idx].ob_x = g.g_x -
+ (slid->x_pos * slid->x_unit_px);
+
+ gw->form[gw->form_idx].ob_y = g.g_y -
+ (slid->y_pos * slid->y_unit_px);
+ }
+
break;
case WM_SIZED:
case WM_REPOSED:
- wind_get_grect(gw->handle, WF_FULLXYWH, &g2);
+ wind_get_grect(gw->handle, WF_FULLXYWH, &g2);
wind_get_grect(gw->handle, WF_CURRXYWH, &g);
g.g_w = MIN(msg[6], g2.g_w);
g.g_h = MIN(msg[7], g2.g_h);
- if(g2.g_w != g.g_w || g2.g_h != g.g_h){
- wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, g.g_w, g.g_h);
- if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
- if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)) {
- guiwin_send_redraw(gw, NULL);
- }
- }
+ if(g2.g_w != g.g_w || g2.g_h != g.g_h) {
+ wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, g.g_w, g.g_h);
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+ if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)) {
+ guiwin_send_redraw(gw, NULL);
+ }
+ }
}
@@ -205,7 +225,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WM_FULLED:
wind_get_grect(gw->handle, WF_FULLXYWH, &g);
wind_get_grect(gw->handle, WF_CURRXYWH, &g2);
- if(g.g_w == g2.g_w && g.g_h == g2.g_h){
+ if(g.g_w == g2.g_w && g.g_h == g2.g_h) {
wind_get_grect(gw->handle, WF_PREVXYWH, &g);
}
wind_set_grect(gw->handle, WF_CURRXYWH, &g);
@@ -243,6 +263,13 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
g.g_h = msg[7];
guiwin_toolbar_redraw(gw, &g);
}
+ if (gw->form != NULL) {
+ g.g_x = msg[4];
+ g.g_y = msg[5];
+ g.g_w = msg[6];
+ g.g_h = msg[7];
+ guiwin_form_redraw(gw, &g);
+ }
break;
default:
@@ -254,6 +281,182 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
return(retval);
}
+static short preproc_mu_button(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
+{
+ short retval = 0;
+
+ DEBUG_PRINT(("preproc_mu_button\n"));
+
+ // toolbar handling:
+ if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0
+ && gw->toolbar != NULL) {
+
+ GRECT tb_area;
+
+ guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area);
+
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, tb_area)) {
+ // send WM_TOOLBAR message
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area.g_y;
+ short obj_idx = objc_find(gw->toolbar,
+ gw->toolbar_idx, 8,
+ ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+
+ DEBUG_PRINT(("Toolbar index: %d\n", obj_idx));
+ if (obj_idx > 0) {
+ if ((gw->toolbar[obj_idx].ob_flags & OF_SELECTABLE)!=0
+ && ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0)
+ && ((gw->flags & GW_FLAG_TOOLBAR_REDRAW) == 1)) {
+ gw->toolbar[obj_idx].ob_state |= OS_SELECTED;
+ // TODO: optimize redraw by setting the object clip:
+ guiwin_toolbar_redraw(gw, NULL);
+ }
+ }
+
+ short oldevents = ev_out->emo_events;
+ short msg_out[8] = {WM_TOOLBAR, gl_apid,
+ 0, gw->handle,
+ obj_idx, ev_out->emo_mclicks,
+ ev_out->emo_kmeta, 0
+ };
+ ev_out->emo_events = MU_MESAG;
+ // notify the window about toolbar click:
+ gw->handler_func(gw, ev_out, msg_out);
+ ev_out->emo_events = oldevents;
+ retval = 1;
+ }
+ }
+
+ if (gw->form != NULL) {
+
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid;
+
+ DEBUG_PRINT(("preproc_mu_button: handling form click.\n"));
+
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &content_area);
+
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, content_area)) {
+
+ slid = guiwin_get_scroll_info(gw);
+
+ gw->form[gw->form_idx].ob_x = content_area.g_x -
+ (slid->x_pos * slid->x_unit_px);
+ gw->form[gw->form_idx].ob_y = content_area.g_y -
+ (slid->y_pos * slid->y_unit_px);
+
+ gw->form_focus_obj = objc_find(gw->form, gw->form_idx, 8,
+ ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y);
+
+ DEBUG_PRINT(("Window Form click, obj: %d\n", gw->form_focus_obj));
+ if (gw->form_focus_obj > -1
+ && (gw->form[gw->form_focus_obj].ob_state & OS_DISABLED)== 0) {
+
+ uint16_t type = (gw->form[gw->form_focus_obj].ob_type & 0xFF);
+ uint16_t xtype = (gw->form[gw->form_focus_obj].ob_type & 0xFF00);
+ uint16_t nextobj, edit_idx;
+
+ DEBUG_PRINT(("type: %d, xtype: %d\n", type, xtype));
+
+ if (type == G_FTEXT || type == G_FBOXTEXT) {
+
+ // report mouse click to the tree:
+ retval = form_button(gw->form, gw->form_focus_obj,
+ ev_out->emo_mclicks, &nextobj);
+
+ // end edit mode for active edit object:
+ if(gw->form_edit_obj != -1) {
+ objc_edit(gw->form, gw->form_edit_obj,
+ ev_out->emo_kreturn, &edit_idx,
+ EDEND);
+ }
+
+ // activate the new edit object:
+ gw->form_edit_obj = gw->form_focus_obj;
+ objc_edit(gw->form, gw->form_edit_obj,
+ ev_out->emo_kreturn, &edit_idx,
+ EDINIT);
+
+ } else {
+
+ // end edit mode for active edit object:
+ if(gw->form_edit_obj != -1) {
+ objc_edit(gw->form, gw->form_edit_obj,
+ ev_out->emo_kreturn, &edit_idx,
+ EDEND);
+ gw->form_edit_obj = -1;
+ }
+
+ if ((xtype & GW_XTYPE_CHECKBOX) != 0) {
+
+ if ((gw->form[gw->form_focus_obj].ob_state & OS_SELECTED) != 0) {
+ gw->form[gw->form_focus_obj].ob_state &= ~(OS_SELECTED|OS_CROSSED);
+ } else {
+ gw->form[gw->form_focus_obj].ob_state |= (OS_SELECTED|OS_CROSSED);
+ }
+ guiwin_form_redraw(gw, obj_screen_rect(gw->form,
+ gw->form_focus_obj));
+ }
+ short oldevents = ev_out->emo_events;
+ short msg_out[8] = {GUIWIN_WM_FORM, gl_apid,
+ 0, gw->handle,
+ gw->form_focus_obj, ev_out->emo_mclicks,
+ ev_out->emo_kmeta, 0
+ };
+ ev_out->emo_events = MU_MESAG;
+ // notify the window about form click:
+ gw->handler_func(gw, ev_out, msg_out);
+ ev_out->emo_events = oldevents;
+ retval = 1;
+ evnt_timer(150);
+ }
+ }
+ }
+ }
+
+ return(retval);
+}
+
+static short preproc_mu_keybd(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
+{
+
+ if((gw->form != NULL) && (gw->form_edit_obj > -1) ) {
+
+ short next_edit_obj = gw->form_edit_obj;
+ short next_char = -1;
+ short edit_idx;
+ short r;
+
+ r = form_keybd(gw->form, gw->form_edit_obj, next_edit_obj,
+ ev_out->emo_kreturn,
+ &next_edit_obj, &next_char);
+
+ if (next_edit_obj != gw->form_edit_obj) {
+
+ if(gw->form_edit_obj != -1) {
+ objc_edit(gw->form, gw->form_edit_obj,
+ ev_out->emo_kreturn, &edit_idx,
+ EDEND);
+ }
+
+ gw->form_edit_obj = next_edit_obj;
+
+ objc_edit(gw->form, gw->form_edit_obj,
+ ev_out->emo_kreturn, &edit_idx,
+ EDINIT);
+ } else {
+ if(next_char > 13)
+ r = objc_edit(gw->form, gw->form_edit_obj,
+ ev_out->emo_kreturn, &edit_idx,
+ EDCHAR);
+ }
+ }
+}
+
short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
{
GUIWIN *dest;
@@ -311,50 +514,22 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
dest = guiwin_find(h_aes);
- if(dest == NULL || dest->handler_func == NULL)
+ if (dest == NULL || dest->handler_func == NULL)
return(0);
- if( (ev_out->emo_events & MU_BUTTON) != 0) {
- DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
+ if ((ev_out->emo_events & MU_BUTTON) != 0) {
- // toolbar handling:
- if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0
- && dest->toolbar != NULL) {
- GRECT tb_area;
- guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
- if (POINT_WITHIN(ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, tb_area)) {
- // send WM_TOOLBAR message
- dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
- dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
- short obj_idx = objc_find(dest->toolbar,
- dest->toolbar_idx, 8,
- ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
- DEBUG_PRINT(("Toolbar index: %d\n", obj_idx));
- short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
- obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0
- };
- if (obj_idx > 0) {
- if ((dest->toolbar[obj_idx].ob_flags & OF_SELECTABLE)!=0
- && ((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0)
- && ((dest->flags & GW_FLAG_TOOLBAR_REDRAW) == 1)) {
- dest->toolbar[obj_idx].ob_state |= OS_SELECTED;
- // TODO: optimize redraw by setting the object clip:
- guiwin_toolbar_redraw(dest, NULL);
- }
- }
-
- short oldevents = ev_out->emo_events;
- ev_out->emo_events = MU_MESAG;
- // notify the window about toolbar click:
- dest->handler_func(dest, ev_out, msg_out);
- handler_called=true;
- ev_out->emo_events = oldevents;
- retval = 1;
- }
+ DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
+ retval = preproc_mu_button(dest, ev_out, msg);
+ if(retval != 0) {
+ handler_called = true;
}
}
+
+ if ((ev_out->emo_events & MU_KEYBD)) {
+ retval = preproc_mu_keybd(dest, ev_out, msg);
+ }
+
if (handler_called==false) {
dest->handler_func(dest, ev_out, msg);
}
@@ -458,7 +633,7 @@ short guiwin_remove(GUIWIN *win)
void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
{
- assert(win != NULL);
+ assert(win != NULL);
wind_get_grect(win->handle, WF_WORKXYWH, dest);
if (mode == GUIWIN_AREA_CONTENT) {
@@ -502,9 +677,9 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_h/slid->y_unit_px;
newpos = slid->y_pos = MIN(slid->y_units-vis_units,
MAX(0, slid->y_pos+units));
- if(newpos < 0){
- newpos = slid->y_pos = 0;
- }
+ if(newpos < 0) {
+ newpos = slid->y_pos = 0;
+ }
if(oldpos == newpos)
return;
@@ -538,9 +713,9 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
newpos = slid->x_pos = MIN(slid->x_units-vis_units,
MAX(0, slid->x_pos+units));
- if(newpos < 0){
- newpos = slid->x_pos = 0;
- }
+ if(newpos < 0) {
+ newpos = slid->x_pos = 0;
+ }
if(oldpos == newpos)
return;
@@ -656,6 +831,7 @@ void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags)
{
win->toolbar = toolbar;
win->toolbar_idx = idx;
+ win->toolbar_edit_obj = -1;
if(flags & GW_FLAG_HAS_VTOOLBAR) {
win->flags |= GW_FLAG_HAS_VTOOLBAR;
}
@@ -677,30 +853,30 @@ struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) {
void guiwin_set_scroll_grid(GUIWIN * win, short x, short y)
{
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(win);
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(win);
- assert(slid != NULL);
+ assert(slid != NULL);
- slid->y_unit_px = x;
- slid->x_unit_px = y;
+ slid->y_unit_px = x;
+ slid->x_unit_px = y;
}
void guiwin_set_content_units(GUIWIN * win, short x, short y)
{
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(win);
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(win);
- assert(slid != NULL);
+ assert(slid != NULL);
- slid->x_units = x;
- slid->y_units = y;
+ slid->x_units = x;
+ slid->y_units = y;
}
void guiwin_send_msg(GUIWIN *win, short msg_type, short a, short b, short c,
- short d)
+ short d)
{
- short msg[8];
+ short msg[8];
- msg[0] = msg_type;
+ msg[0] = msg_type;
msg[1] = gl_apid;
msg[2] = 0;
msg[3] = win->handle;
@@ -714,32 +890,32 @@ void guiwin_send_msg(GUIWIN *win, short msg_type, short a, short b, short c,
void guiwin_send_redraw(GUIWIN *win, GRECT *area)
{
- short msg[8];
+ short msg[8], retval;
GRECT work;
EVMULT_IN event_in = {
- .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
- .emi_bclicks = 258,
- .emi_bmask = 3,
- .emi_bstate = 0,
- .emi_m1leave = MO_ENTER,
- .emi_m1 = {0,0,0,0},
- .emi_m2leave = 0,
- .emi_m2 = {0,0,0,0},
- .emi_tlow = 0,
- .emi_thigh = 0
- };
- EVMULT_OUT event_out;
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_bclicks = 258,
+ .emi_bmask = 3,
+ .emi_bstate = 0,
+ .emi_m1leave = MO_ENTER,
+ .emi_m1 = {0,0,0,0},
+ .emi_m2leave = 0,
+ .emi_m2 = {0,0,0,0},
+ .emi_tlow = 0,
+ .emi_thigh = 0
+ };
+ EVMULT_OUT event_out;
if (area == NULL) {
guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
if (work.g_w < 1 || work.g_h < 1) {
- if (win->toolbar != NULL) {
- guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &work);
- if (work.g_w < 1 || work.g_h < 1) {
- return;
- }
- }
+ if (win->toolbar != NULL) {
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &work);
+ if (work.g_w < 1 || work.g_h < 1) {
+ return;
+ }
+ }
}
area = &work;
}
@@ -753,13 +929,25 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
msg[6] = area->g_w;
msg[7] = area->g_h;
- event_out.emo_events = MU_MESAG;
- win->handler_func(win, &event_out, msg);
+ event_out.emo_events = MU_MESAG;
+ retval = preproc_wm(win, &event_out, msg);
+ if (retval == 0 || (win->flags & GW_FLAG_PREPROC_WM) != 0){
+ win->handler_func(win, &event_out, msg);
+ }
+
+
//appl_write(gl_apid, 16, &msg);
}
-
+void guiwin_set_form(GUIWIN *win, OBJECT *tree, short index)
+{
+ DEBUG_PRINT(("Setting form %p (%d) for window %p\n", tree, index, win));
+ win->form = tree;
+ win->form_edit_obj = -1;
+ win->form_focus_obj = -1;
+ win->form_idx = index;
+}
bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
{
@@ -815,6 +1003,47 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
}
}
+
+void guiwin_form_redraw(GUIWIN *gw, GRECT *clip)
+{
+ GRECT area, area_ro, g;
+ int scroll_px_x, scroll_px_y;
+ struct guiwin_scroll_info_s *slid;
+ //int new_x, new_y, old_x, old_y;
+ short edit_idx;
+
+ DEBUG_PRINT(("guiwin_form_redraw\n"));
+
+ // calculate form coordinates, include scrolling:
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &area_ro);
+ slid = guiwin_get_scroll_info(gw);
+
+ // Update form position:
+ gw->form[gw->form_idx].ob_x = area_ro.g_x - (slid->x_pos * slid->x_unit_px);
+ gw->form[gw->form_idx].ob_y = area_ro.g_y - (slid->y_pos * slid->y_unit_px);
+
+ if(clip == NULL) {
+ clip = &area_ro;
+ }
+
+ area = area_ro;
+
+ /* Walk the AES rectangle list and redraw the visible areas of the window:*/
+ if(rc_intersect(clip, &area)) {
+
+ wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ if(rc_intersect(&area, &g)) {
+ objc_draw(gw->form, gw->form_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+
+ }
+ wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
+ }
+ }
+}
+
+
void guiwin_clear(GUIWIN *win)
{
GRECT area, g;
@@ -823,7 +1052,7 @@ void guiwin_clear(GUIWIN *win)
vh = guiwin_get_vdi_handle(win);
- if(win->state & GW_STATUS_ICONIFIED){
+ if(win->state & GW_STATUS_ICONIFIED) {
// also clear the toolbar area when iconified:
guiwin_get_grect(win, GUIWIN_AREA_WORK, &area);
} else {
diff --git a/atari/gemtk/objc.c b/atari/gemtk/objc.c
new file mode 100644
index 000000000..90c4d88ac
--- /dev/null
+++ b/atari/gemtk/objc.c
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ *
+ * AES Object tree tools.
+ *
+ */
+
+ #include "gemtk.h"
+
+
+OBJECT *get_tree(int idx)
+{
+
+ OBJECT *tree;
+
+ rsrc_gaddr(R_TREE, idx, &tree);
+
+ return tree;
+}
+
+bool obj_is_inside(OBJECT * tree, short obj, GRECT *area)
+{
+ GRECT obj_screen;
+ bool ret = false;
+
+ objc_offset(tree, obj, &obj_screen.g_x, &obj_screen.g_y);
+ obj_screen.g_w = tree[obj].ob_width;
+ obj_screen.g_h = tree[obj].ob_height;
+
+ ret = RC_WITHIN(&obj_screen, area);
+
+ return(ret);
+}
+
+GRECT * obj_screen_rect(OBJECT * tree, short obj)
+{
+ static GRECT obj_screen;
+
+ get_objframe(tree, obj, &obj_screen);
+
+ return(&obj_screen);
+}
diff --git a/atari/gemtk/objc.h b/atari/gemtk/objc.h
new file mode 100644
index 000000000..6fa1072b7
--- /dev/null
+++ b/atari/gemtk/objc.h
@@ -0,0 +1,7 @@
+#ifndef GEMTK_OBJC_H
+#define GEMTK_OBJC_H
+
+
+
+#endif // GEMTK_OBJC_H
+
diff --git a/atari/gemtk/utils.c b/atari/gemtk/utils.c
index 4a24d8261..82f74f965 100644
--- a/atari/gemtk/utils.c
+++ b/atari/gemtk/utils.c
@@ -38,8 +38,3 @@ unsigned short _systype (void)
return _systype_v;
}
-OBJECT *get_tree( int idx) {
- OBJECT *tree;
- rsrc_gaddr(R_TREE, idx, &tree);
- return tree;
-}
diff --git a/atari/gui.c b/atari/gui.c
index 888f82d37..ccf7c21ae 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -715,7 +715,7 @@ void gui_start_selection(struct gui_window *w)
void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
{
- char * clip = scrap_txt_read( &app );
+ char * clip = scrap_txt_read();
if( clip == NULL )
return;
int clip_length = strlen( clip );
@@ -731,8 +731,9 @@ void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
strlen(utf8), true);
free(utf8);
}
- free( clip );
}
+
+ free( clip );
}
bool gui_empty_clipboard(void)
@@ -812,7 +813,7 @@ fin:
bool gui_commit_clipboard(void)
{
- int r = scrap_txt_write(&app, tmp_clipboard);
+ int r = scrap_txt_write(tmp_clipboard);
return( (r>0)?true:false );
}
diff --git a/atari/history.h b/atari/history.h
index 3ea2621bf..6185e2ac0 100755
--- a/atari/history.h
+++ b/atari/history.h
@@ -20,7 +20,6 @@
#define NS_ATARI_HISTORY_H
#include <stdbool.h>
-#include <windom.h>
#include "desktop/tree.h"
#include "atari/treeview.h"
#include "atari/gemtk/gemtk.h"
diff --git a/atari/hotlist.h b/atari/hotlist.h
index ed965a5a7..9fbf38932 100755
--- a/atari/hotlist.h
+++ b/atari/hotlist.h
@@ -19,7 +19,6 @@
#ifndef NS_ATARI_HOTLIST_H
#define NS_ATARI_HOTLIST_H
#include <stdbool.h>
-#include <windom.h>
#include "desktop/tree.h"
#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
diff --git a/atari/search.c b/atari/search.c
index 473712515..cc58caa7b 100644
--- a/atari/search.c
+++ b/atari/search.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Ole Loots <ole@monochrom.net>
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -14,7 +14,13 @@
*
* 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>
@@ -39,10 +45,14 @@
#include "atari/res/netsurf.rsh"
extern struct gui_window * input_window;
-extern void * h_gem_rsrc;
+extern void * h_gem_rsrc;
+extern GRECT desk_area;
-static SEARCH_FORM_SESSION current;
+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);
@@ -80,7 +90,7 @@ void nsatari_search_set_hourglass(bool active, void *p)
{
SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
LOG((""));
- if( active && current != NULL )
+ 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);
@@ -127,22 +137,22 @@ void nsatari_search_set_back_state(bool active, void *p)
}
-static SEARCH_FORM_SESSION get_search_session(WINDOW * win)
+static SEARCH_FORM_SESSION get_search_session(GUIWIN * win)
{
return (current);
}
-static void destroy_search_session( SEARCH_FORM_SESSION s )
+static void destroy_search_session(SEARCH_FORM_SESSION s)
{
- if( s != NULL ){
+ if(s != NULL ){
LOG((""));
- free( s );
+ free(s);
}
}
-static int apply_form(WINDOW * win, struct s_search_form_state * s)
+static int apply_form(GUIWIN *win, struct s_search_form_state * s)
{
- OBJECT * obj = ObjcTree(OC_FORM, win );
+ OBJECT * obj = dlgtree;
if( obj == NULL ){
goto error;
}
@@ -167,15 +177,15 @@ error:
return( 1 );
}
-/* checks if search parameters changes */
-static bool form_changed( WINDOW * w )
+/* 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 = ObjcTree(OC_FORM, w);
+ OBJECT * obj = (OC_FORM, w);
assert( s != NULL && obj != NULL );
uint32_t flags_old = s->state.flags;
apply_form(w, &cur);
@@ -188,9 +198,9 @@ static bool form_changed( WINDOW * w )
}
char * cstr = ObjcString( obj, SEARCH_TB_SRCH, NULL );
- if( cstr != NULL ){
- if( strcmp(cstr, (char*)&s->state.text) != 0 ) {
- return ( true );
+ if (cstr != NULL){
+ if (strcmp(cstr, (char*)&s->state.text) != 0) {
+ return (true);
}
}
@@ -202,14 +212,14 @@ static void __CDECL evnt_bt_srch_click( WINDOW *win, int index, int unused, void
{
bool fwd;
- SEARCH_FORM_SESSION s = get_search_session(win);
- OBJECT * obj = ObjcTree(OC_FORM, s->formwind );
+ SEARCH_FORM_SESSION s = get_search_session(searchwin);
+ OBJECT * obj = dlgtree;
search_flags_t flags = 0;
ObjcChange(OC_FORM, win, index, ~SELECTED , TRUE);
- if( form_changed(win) ){
+ if( form_changed(searchwin) ){
browser_window_search_destroy_context(s->bw);
- apply_form( win, &s->state );
+ apply_form(searchwin, &s->state );
} else {
/* get search direction manually: */
if( (obj[SEARCH_CB_FWD].ob_state & SELECTED) != 0 )
@@ -227,78 +237,93 @@ static void __CDECL evnt_cb_click( WINDOW *win, int index, int unused, void *unu
{
short newstate;
- OBJECT * obj = ObjcTree(OC_FORM, get_search_session(win)->formwind );
+
}
static void __CDECL evnt_close( WINDOW *win, short buff[8])
{
- /* Free Search Contexts */
- /* todo: destroy search context, if any? */
- SEARCH_FORM_SESSION s = get_search_session(win);
- if( s != NULL ){
- destroy_search_session( s );
- }
- current = NULL;
- ApplWrite( _AESapid, WM_DESTROY, win->handle, 0,0,0,0 );
-}
-void search_destroy( struct gui_window * gw )
-{
- LOG(("search_destroy %p / %p", gw, current ));
- if( current != NULL && current->formwind != NULL ){
- ApplWrite( _AESapid, WM_CLOSED, current->formwind->handle, 0,0,0,0);
- /* Handle Close event */
- EvntWindom( MU_MESAG );
- /* Handle Destroy Event */
- EvntWindom( MU_MESAG );
- }
- LOG(("done"));
}
+
+void search_destroy(struct gui_window *gw)
+{
+ /* Free Search Contexts */
+ /* todo: destroy search context, if any? */
+ LOG((""));
-SEARCH_FORM_SESSION open_browser_search( struct gui_window * gw )
+ 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;
- OBJECT * tree = get_tree(SEARCH);
- if( tree == NULL ){
- return( NULL );
- }
+ 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 ...";
-
- search_destroy( gw );
-
+ if (title == NULL)
+ title = (char*)"Find text ...";
+
/* setup dipslay position: right corner */
treesize.g_x = 0;
treesize.g_y = 0;
- treesize.g_w = tree->ob_width;
- treesize.g_h = tree->ob_height;
- wind_calc_grect(WC_BORDER, WAT_FORM, &treesize, &pos);
- pos.g_x = app.w - pos.g_w;
- pos.g_y = app.h - pos.g_h;
+ 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->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(sfs->formwind, &sfs->state );
- strncpy( ObjcString( tree, SEARCH_TB_SRCH, NULL ), "", SEARCH_MAX_SLEN);
+*/
+ apply_form(searchwin, &sfs->state );
+ set_string(dlgtree, SEARCH_TB_SRCH, "");
return( current );
diff --git a/atari/search.h b/atari/search.h
index 7913803cd..9228b9623 100644
--- a/atari/search.h
+++ b/atari/search.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Ole Loots <ole@monochrom.net>
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -14,7 +14,13 @@
*
* 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
@@ -29,7 +35,6 @@ struct s_search_form_state
struct s_search_form_session {
struct browser_window * bw;
- WINDOW * formwind;
struct s_search_form_state state;
};
@@ -37,6 +42,6 @@ struct s_search_form_session {
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 );
+void search_destroy(struct gui_window * gw);
#endif
diff --git a/atari/settings.c b/atari/settings.c
index 90404c13b..c5cc3ae52 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -59,7 +59,7 @@ static OBJECT * dlgtree;
guiwin_send_redraw(settings_guiwin, \
obj_screen_rect(dlgtree, idx));
-#define FORMEVENT(idx) form_event(idx, 0, NULL);
+#define FORMEVENT(idx) form_event(idx, 0);
#define INPUT_HOMEPAGE_URL_MAX_LEN 44
#define INPUT_LOCALE_MAX_LEN 6
@@ -73,37 +73,12 @@ static OBJECT * dlgtree;
#define LABEL_ICONSET_MAX_LEN 8
#define INPUT_TOOLBAR_COLOR_MAX_LEN 6
-#define CB_SELECTED (OS_SELECTED | OS_CROSSED)
-
static void on_close(void);
static void on_redraw(GRECT *clip);
-static void form_event(int index, int external, void *unused2);
+static void form_event(int index, int external);
static void apply_settings(void);
static void save_settings(void);
-static bool obj_is_inside(OBJECT * tree, short obj, GRECT *area)
-{
- GRECT obj_screen;
- bool ret = false;
-
- objc_offset(tree, obj, &obj_screen.g_x, &obj_screen.g_y);
- obj_screen.g_w = dlgtree[obj].ob_width;
- obj_screen.g_h = dlgtree[obj].ob_height;
-
- ret = RC_WITHIN(&obj_screen, area);
-
- return(ret);
-}
-
-static GRECT * obj_screen_rect(OBJECT * tree, short obj)
-{
- static GRECT obj_screen;
-
- get_objframe(tree, obj, &obj_screen);
-
- return(&obj_screen);
-}
-
static void set_text( short idx, char * text, int len )
{
@@ -234,21 +209,21 @@ static void display_settings(void)
set_text( SETTINGS_BT_SEL_FONT_RENDERER, nsoption_charp(atari_font_driver),
LABEL_FONT_RENDERER_MAX_LEN );
SET_BIT(dlgtree[SETTINGS_CB_TRANSPARENCY].ob_state,
- CB_SELECTED, nsoption_int(atari_transparency) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_int(atari_transparency) ? 1 : 0 );
SET_BIT(dlgtree[SETTINGS_CB_ENABLE_ANIMATION].ob_state,
- CB_SELECTED, nsoption_bool(animate_images) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_bool(animate_images) ? 1 : 0 );
SET_BIT(dlgtree[SETTINGS_CB_FG_IMAGES].ob_state,
- CB_SELECTED, nsoption_bool(foreground_images) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_bool(foreground_images) ? 1 : 0 );
SET_BIT(dlgtree[SETTINGS_CB_BG_IMAGES].ob_state,
- CB_SELECTED, nsoption_bool(background_images) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_bool(background_images) ? 1 : 0 );
/*
TODO: enable this option?
SET_BIT(dlgtree[SETTINGS_CB_INCREMENTAL_REFLOW].ob_state,
- CB_SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 );
*/
SET_BIT(dlgtree[SETTINGS_CB_ANTI_ALIASING].ob_state,
- CB_SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 );
+ GW_CB_SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 );
/*
TODO: activate this option?
@@ -274,9 +249,9 @@ static void display_settings(void)
set_text( SETTINGS_EDIT_PROXY_PASSWORD, nsoption_charp(http_proxy_auth_pass),
INPUT_PROXY_PASSWORD_MAX_LEN );
SET_BIT(dlgtree[SETTINGS_CB_USE_PROXY].ob_state,
- CB_SELECTED, nsoption_bool(http_proxy) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_bool(http_proxy) ? 1 : 0 );
SET_BIT(dlgtree[SETTINGS_CB_PROXY_AUTH].ob_state,
- CB_SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 );
+ GW_CB_SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 );
tmp_option_max_cached_fetch_handles = nsoption_int(max_cached_fetch_handles);
snprintf( spare, 255, "%2d", nsoption_int(max_cached_fetch_handles) );
@@ -304,7 +279,7 @@ static void display_settings(void)
}
-static void form_event(int index, int external, void *unused2)
+static void form_event(int index, int external)
{
char spare[255];
bool is_button = false;
@@ -327,36 +302,15 @@ static void form_event(int index, int external, void *unused2)
short x, y;
int choice;
- // TODO: set correct form coords.
-
- switch( index ){
+ switch(index){
case SETTINGS_SAVE:
save_settings();
- //save_settings();
- break;
-
-
- case SETTINGS_INC_HISTORY_AGE:
- case SETTINGS_DEC_HISTORY_AGE:
- if(index == SETTINGS_INC_HISTORY_AGE)
- tmp_option_expire_url += 1;
- else
- tmp_option_expire_url -= 1;
-
- if(tmp_option_expire_url > 99)
- tmp_option_expire_url = 0;
-
- snprintf( spare, 255, "%02d", tmp_option_expire_url);
- set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 );
- OBJ_REDRAW(SETTINGS_EDIT_HISTORY_AGE);
- is_button = true;
-
- default: break;
- }
-
+ break;
- switch(index){
+ case SETTINGS_ABORT:
+ close_settings();
+ break;
case SETTINGS_CB_USE_PROXY:
if( checked ){
@@ -398,13 +352,13 @@ static void form_event(int index, int external, void *unused2)
case SETTINGS_BT_SEL_FONT_RENDERER:
if( external ){
objc_offset(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER, &x, &y);
- choice = MenuPopUp ( font_driver_items, x, y,
+ choice = MenuPopUp (font_driver_items, x, y,
num_font_drivers,
-1, -1, P_LIST + P_WNDW + P_CHCK );
if( choice > 0 &&
choice <= num_font_drivers ){
set_text(SETTINGS_BT_SEL_FONT_RENDERER,
- font_driver_items[choice-1],
+ (char*)font_driver_items[choice-1],
LABEL_FONT_RENDERER_MAX_LEN);
OBJ_REDRAW(SETTINGS_BT_SEL_FONT_RENDERER);
}
@@ -423,7 +377,7 @@ static void form_event(int index, int external, void *unused2)
num_locales,
-1, -1, P_LIST + P_WNDW + P_CHCK );
if( choice > 0 && choice <= num_locales ){
- set_text(SETTINGS_BT_SEL_LOCALE, locales[choice-1], 5);
+ set_text(SETTINGS_BT_SEL_LOCALE, (char*)locales[choice-1], 5);
}
OBJ_REDRAW(SETTINGS_BT_SEL_LOCALE);
break;
@@ -607,43 +561,6 @@ static void form_event(int index, int external, void *unused2)
}
}
-static void on_redraw(GRECT *clip)
-{
- GRECT visible, work, clip_ro;
- int scroll_px_x, scroll_px_y;
- struct guiwin_scroll_info_s *slid;
- int new_x, new_y, old_x, old_y;
- short edit_idx;
-
- /* Walk the AES rectangle list and redraw the visible areas of the window: */
- guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &work);
- slid = guiwin_get_scroll_info(settings_guiwin);
-
- old_x = dlgtree->ob_x;
- old_y = dlgtree->ob_y;
- dlgtree->ob_x = new_x = work.g_x - (slid->x_pos * slid->x_unit_px);
- dlgtree->ob_y = new_y = work.g_y - (slid->y_pos * slid->y_unit_px);
-
- if ((edit_obj > -1) && (obj_is_inside(dlgtree, edit_obj, &work) == true)) {
- dlgtree->ob_x = old_x;
- dlgtree->ob_y = old_y;
- objc_edit(dlgtree, edit_obj, 0, &edit_idx,
- EDEND);
- edit_obj = -1;
-
- dlgtree->ob_x = new_x;
- dlgtree->ob_y = new_y;
- }
-
- wind_get_grect(h_aes_win, WF_FIRSTXYWH, &visible);
- while (visible.g_x && visible.g_y) {
- if (rc_intersect(clip, &visible)) {
- objc_draw_grect(dlgtree, 0, 8, &visible);
- }
- wind_get_grect(h_aes_win, WF_NEXTXYWH, &visible);
- }
-}
-
static void apply_settings(void)
{
@@ -732,21 +649,15 @@ static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
short retval = 0;
GRECT clip, work;
static short edit_idx = 0;
+ struct guiwin_scroll_info_s *slid;
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
// printf("settings win msg: %d\n", msg[0]);
switch (msg[0]) {
- case WM_REDRAW:
- clip.g_x = msg[4];
- clip.g_y = msg[5];
- clip.g_w = msg[6];
- clip.g_h = msg[7];
- on_redraw(&clip);
- break;
- case WM_CLOSED:
+ case WM_CLOSED:
// TODO: this needs to iterate through all gui windows and
// check if the rootwin is this window...
close_settings();
@@ -756,90 +667,28 @@ static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
guiwin_update_slider(win, GUIWIN_VH_SLIDER);
break;
+ case WM_MOVED:
+ break;
+
case WM_TOOLBAR:
switch(msg[4]){
default: break;
}
break;
+ case GUIWIN_WM_FORM:
+ form_event(msg[4], 1);
+ break;
+
default:
break;
}
}
- if ((ev_out->emo_events & MU_KEYBD) != 0) {
-
- if((edit_obj > -1) /* && obj_is_inside(dlgtree, edit_obj, &work) */){
-
- short next_edit_obj = edit_obj;
- short next_char = -1;
- short r;
-
- guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &work);
-
- r = form_keybd(dlgtree, edit_obj, next_edit_obj, ev_out->emo_kreturn,
- &next_edit_obj, &next_char);
- if (next_edit_obj != edit_obj) {
- objc_edit(dlgtree, edit_obj, ev_out->emo_kreturn, &edit_idx,
- EDEND);
- edit_obj = next_edit_obj;
- objc_edit(dlgtree, edit_obj, ev_out->emo_kreturn, &edit_idx,
- EDINIT);
- } else {
- if(next_char > 13)
- r = objc_edit(dlgtree, edit_obj, ev_out->emo_kreturn, &edit_idx,
- EDCHAR);
- }
-
- }
+ if ((ev_out->emo_events & MU_KEYBD) != 0) {
}
- if ((ev_out->emo_events & MU_BUTTON) != 0) {
-
- struct guiwin_scroll_info_s *slid;
- short nextobj, ret=-1;
-
- guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &work);
-
- slid = guiwin_get_scroll_info(settings_guiwin);
- dlgtree->ob_x = work.g_x - (slid->x_pos * slid->x_unit_px);
- dlgtree->ob_y = work.g_y - (slid->y_pos * slid->y_unit_px);
-
- any_obj = objc_find(dlgtree, 0, 8, ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
-
- if((dlgtree[any_obj].ob_state & OS_DISABLED) != 0) {
- return(retval);
- }
- uint16_t type = (dlgtree[any_obj].ob_type & 0xFF);
- if (type == G_FTEXT || type == G_FBOXTEXT) {
- ret = form_button(dlgtree, any_obj, ev_out->emo_mclicks, &nextobj);
- if(edit_obj != -1){
- if (obj_is_inside(dlgtree, edit_obj, &work)) {
- objc_edit(dlgtree, edit_obj, ev_out->emo_kreturn, &edit_idx, EDEND);
- }
- }
- if (obj_is_inside(dlgtree, any_obj, &work)) {
- edit_obj = any_obj;
- objc_edit(dlgtree, edit_obj, ev_out->emo_kreturn, &edit_idx, EDINIT);
- }
- } else {
- if ((edit_obj != -1) && obj_is_inside(dlgtree, edit_obj, &work)){
- objc_edit(dlgtree, edit_obj, ev_out->emo_kreturn, &edit_idx, EDEND);
- }
- edit_obj = -1;
- if (((dlgtree[any_obj].ob_type & 0xff00) & GW_XTYPE_CHECKBOX) != 0) {
- if (OBJ_SELECTED(any_obj)) {
- dlgtree[any_obj].ob_state &= ~(OS_SELECTED|OS_CROSSED);
- } else {
- dlgtree[any_obj].ob_state |= (OS_SELECTED|OS_CROSSED);
- }
- guiwin_send_redraw(win, obj_screen_rect(dlgtree, any_obj));
- }
- form_event(any_obj, 1, NULL);
- }
- //printf("clicked: %d / %d\n", any_obj, ret);
- evnt_timer(150);
+ if ((ev_out->emo_events & MU_BUTTON) != 0) {
}
return(retval);
@@ -866,8 +715,6 @@ void open_settings(void)
curr.g_w = MIN(dlgtree->ob_width, desk_area.g_w);
curr.g_h = MIN(dlgtree->ob_height, desk_area.g_h-64);
curr.g_x = 1;
- curr.g_y = desk_area.g_y;
- //curr.g_x = (desk_area.g_w / 2) - (curr.g_w / 2);
curr.g_y = (desk_area.g_h / 2) - (curr.g_h / 2);
wind_calc_grect(WC_BORDER, kind, &curr, &curr);
@@ -880,26 +727,26 @@ void open_settings(void)
wind_open_grect(h_aes_win, &curr);
+ guiwin_set_form(settings_guiwin, dlgtree, 0);
guiwin_set_scroll_grid(settings_guiwin, 32, 32);
guiwin_get_grect(settings_guiwin, GUIWIN_AREA_CONTENT, &area);
+
slid = guiwin_get_scroll_info(settings_guiwin);
guiwin_set_content_units(settings_guiwin,
(dlgtree->ob_width/slid->x_unit_px),
(dlgtree->ob_height/slid->y_unit_px));
guiwin_update_slider(settings_guiwin, GUIWIN_VH_SLIDER);
-
}
}
void close_settings(void)
{
-
-
- printf("settings close\n");
+ LOG((""));
guiwin_remove(settings_guiwin);
settings_guiwin = NULL;
wind_close(h_aes_win);
wind_delete(h_aes_win);
h_aes_win = 0;
+ LOG(("Done"));
}
diff --git a/atari/settings.h b/atari/settings.h
index ef6ae8195..87597e6a0 100644
--- a/atari/settings.h
+++ b/atari/settings.h
@@ -1,7 +1,6 @@
#ifndef NS_ATARI_SETTINGS
#define NS_ATARI_SETTINGS
-#include <windom.h>
void open_settings(void);
void close_settings(void);
diff --git a/atari/statusbar.c b/atari/statusbar.c
index bf241e2dc..d43ebc853 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -24,7 +24,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
-#include <windom.h>
#include <assert.h>
#include <math.h>
diff --git a/atari/toolbar.c b/atari/toolbar.c
index c6bd74568..9920b920f 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -585,12 +585,12 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
text = malloc( len+1 );
if (text){
textarea_get_text( tb->url.textarea, text, len+1 );
- scrap_txt_write( &app, text );
+ scrap_txt_write(text);
free( text );
}
}
else if ( ik == KEY_PASTE) {
- char * clip = scrap_txt_read( &app );
+ char * clip = scrap_txt_read();
if ( clip != NULL ){
int clip_length = strlen( clip );
if ( clip_length > 0 ) {
@@ -604,8 +604,8 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
free(utf8);
ret = true;
}
- free( clip );
}
+ free( clip );
}
}
else if (ik == KEY_ESCAPE) {
diff --git a/atari/treeview.h b/atari/treeview.h
index 8683bc349..19b77301e 100755
--- a/atari/treeview.h
+++ b/atari/treeview.h
@@ -20,7 +20,6 @@
#define NS_ATARI_TREEVIEW_H
#include <stdbool.h>
-#include <windom.h>
#include "desktop/tree.h"
#include "atari/gui.h"
#include "atari/gemtk/gemtk.h"