diff options
author | Ole Loots <ole@monochrom.net> | 2012-12-21 00:56:50 +0100 |
---|---|---|
committer | Ole Loots <ole@monochrom.net> | 2012-12-21 00:56:50 +0100 |
commit | f7ee2a03876bf4a5cf66b3a433955e4e55d91362 (patch) | |
tree | 146748923e9aaa464fac29306cc51cb06ef589ec /atari/gemtk | |
parent | 3019368c93600a335445c09178c9554074c7f656 (diff) | |
download | netsurf-f7ee2a03876bf4a5cf66b3a433955e4e55d91362.tar.gz netsurf-f7ee2a03876bf4a5cf66b3a433955e4e55d91362.tar.bz2 |
- started to work on settings dialog
- some WIP in treeview widgets. Changed destroy / and init handling.
It requires some optimization, when the widget is closed
it must remove itself from the guiwin list, for perfomance.
Diffstat (limited to 'atari/gemtk')
-rw-r--r-- | atari/gemtk/aestabs.c | 173 | ||||
-rw-r--r-- | atari/gemtk/aestabs.h | 56 | ||||
-rw-r--r-- | atari/gemtk/gemtk.h | 77 | ||||
-rw-r--r-- | atari/gemtk/guiwin.c | 41 |
4 files changed, 302 insertions, 45 deletions
diff --git a/atari/gemtk/aestabs.c b/atari/gemtk/aestabs.c new file mode 100644 index 000000000..414d5c290 --- /dev/null +++ b/atari/gemtk/aestabs.c @@ -0,0 +1,173 @@ +#include <stdlib.h> +#include <assert.h> +#include <gem.h> +#include <cflib.h> +#include "aestabs.h" + +#ifndef NDEBUG +# define DEBUG_PRINT(x) printf x +#else +# define DEBUG_PRINT(x) +#endif + + +AES_TABLIST * tablist_declare(OBJECT *tree, aes_tablist_user_func user_func) +{ + AES_TABLIST * newlist = malloc(sizeof(AES_TABLIST)); + + newlist->first = NULL; + newlist->tree = tree; + newlist->user_func = user_func; + DEBUG_PRINT(("aes_tablist_declare: %p\n", newlist)); + return(newlist); +} + + +AES_TAB * tablist_add(AES_TABLIST * tablist, short obj_tab, OBJECT * page_tree, + short obj_page) +{ + AES_TAB * newtab = malloc(sizeof(AES_TAB)); + + assert(newtab); + assert(tablist); + + newtab->next = NULL; + newtab->prev = NULL; + newtab->obj_tab = obj_tab; + newtab->obj_page = obj_page; + newtab->page_tree = page_tree; + + if(newtab->page_tree == NULL){ + newtab->page_tree = tablist->tree; + } + + if (tablist->first == NULL) { + tablist->first = newtab; + set_state(tablist->tree, newtab->obj_tab, OS_SELECTED, 0); + } else { + AES_TAB *tmp = tablist->first; + while( tmp->next != NULL ) { + tmp = tmp->next; + } + tmp->next = newtab; + newtab->prev = tmp; + newtab->next = NULL; + set_state(tablist->tree, newtab->obj_tab, OS_SELECTED, 0); + } + + // TODO: Set the visible flag on that register? + + DEBUG_PRINT(("tablist_add: Tab=%p\n", newtab)); + + return(newtab); +} + + +short tablist_activate(AES_TABLIST * tablist, short tab, short options) +{ + AES_TAB *tmp, *activated=NULL, *deactivated=NULL; + struct aes_tab_s *active; + short activated_pg = -1; + short is_tab = 0; + + assert(tablist); + assert(tablist->first); + + active = tablist_get_active(tablist); + + if (active != NULL) { + if ((options & AES_TABLIST_OPTION_FORCE_EVENTS) == 0) { + if(active->obj_tab == tab) + return(0); + } + } + + tmp = tablist->first; + while (tmp != NULL) { + if(tmp->obj_tab == tab) { + is_tab = 1; + } + tmp = tmp->next; + } + + if(is_tab == 0) { + return(0); + } + + tmp = tablist->first; + while ( tmp != NULL ) { + if(tab != tmp->obj_tab) { + if (get_state(tablist->tree, tmp->obj_tab, OS_SELECTED) != 0) { + deactivated = tmp; + set_state(tablist->tree, tmp->obj_tab, OS_SELECTED, 0); + } + // the tab registers can share the same page, consider that: + if (tablist->tree == tmp->page_tree + && activated_pg != tmp->obj_page) { + + set_flag(tablist->tree, tmp->obj_page, OF_HIDETREE, 1); + } + } else { + activated = tmp; + // this tab must the selected / visible + set_state(tablist->tree, tmp->obj_tab, OS_SELECTED, 1); + if(tablist->tree == tmp->page_tree) + set_flag(tablist->tree, tmp->obj_page, OF_HIDETREE, 0); + activated_pg = tmp->obj_page; + } + tmp = tmp->next; + } + + if(tablist->user_func != NULL) { + AES_TABLIST_FUNC_ARGS args; + if(deactivated){ + args.event = AES_TABLIST_TAB_DEACTIVATED; + args.tab = deactivated; + tablist->user_func(tablist, &args); + } + if(activated){ + args.event = AES_TABLIST_TAB_ACTIVATED; + args.tab = activated; + tablist->user_func(tablist, &args); + } + } + return(1); +} + +struct aes_tab_s *tablist_get_active(AES_TABLIST * tablist) +{ + AES_TAB *tmp = tablist->first; + while( tmp != NULL ) { + if(get_state(tablist->tree, tmp->obj_tab, OS_SELECTED) != 0) { + // that's the one + return(tmp); + } + tmp = tmp->next; + } + return(NULL); +} + +AES_TAB * tablist_find(AES_TABLIST * tablist, OBJECT * page, short tab) +{ + AES_TAB *tmp = tablist->first; + while( tmp != NULL ) { + if((tmp->page_tree == page) && (tab == tmp->obj_tab)) { + return(tmp); + } + tmp = tmp->next; + } + return(NULL); +} + +void tablist_delete(AES_TABLIST *tablist) +{ + AES_TAB *tmp = tablist->first, *cur; + while ( tmp != NULL ) { + cur = tmp; + tmp = tmp->next; + DEBUG_PRINT(("tablist_delete, Freeing tab: %p\n", cur)); + free(cur); + } + DEBUG_PRINT(("tablist_delete, Freeing list: %p\n", tablist)); + free(tablist); +} diff --git a/atari/gemtk/aestabs.h b/atari/gemtk/aestabs.h new file mode 100644 index 000000000..c72054acc --- /dev/null +++ b/atari/gemtk/aestabs.h @@ -0,0 +1,56 @@ +#ifndef AESTABS_H_INCLUDED
+#define AESTABS_H_INCLUDED
+ +struct aes_tab_s; +struct aes_tablist_s; +typedef struct aes_tab_s AES_TAB; +typedef struct aes_tablist_s AES_TABLIST; + +#define AES_TABLIST_TAB_ACTIVATED 0x01 +#define AES_TABLIST_TAB_DEACTIVATED 0x02 + +#define AES_TABLIST_OPTION_FORCE_EVENTS 0x01 // do not eat events which do + // not changed the internal state + // this is required for tabs which + // require "activate" events + // for tabs which are already + // selected. + + +struct aes_tablist_user_args_s +{ + short event; + AES_TAB *tab; +}; + +typedef struct aes_tablist_user_args_s AES_TABLIST_FUNC_ARGS; + +typedef void (*aes_tablist_user_func)(AES_TABLIST * list, + AES_TABLIST_FUNC_ARGS * args); + +struct aes_tab_s { + short obj_tab; + short obj_page; + OBJECT * page_tree; + AES_TAB * next, *prev; +}; + +struct aes_tablist_s { + OBJECT *tree; + AES_TAB * first; + aes_tablist_user_func user_func; +}; + + + +AES_TABLIST * tablist_declare(OBJECT *tree, aes_tablist_user_func user_func); +void tablist_delete(AES_TABLIST * tablist); +AES_TAB * tablist_add(AES_TABLIST * tablist, short tab, OBJECT *page_tree, + short page); +short tablist_activate(AES_TABLIST * tablist, short tab, short option); +struct aes_tab_s *tablist_get_active(AES_TABLIST * tablist); +AES_TAB * tablist_find(AES_TABLIST * tablist, OBJECT *page, short tab); + +#define AES_TAB_IS_ACTIVE(l, x) (tablist_get_active(l) == x) +
+#endif // AESTABS_H_INCLUDED
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h index 1225a0ccd..9c341ba5c 100644 --- a/atari/gemtk/gemtk.h +++ b/atari/gemtk/gemtk.h @@ -7,6 +7,10 @@ #include <stdint.h> #include <stdbool.h> +/* -------------------------------------------------------------------------- */ +/* Utils */ +/* -------------------------------------------------------------------------- */ + /* System type detection added by [GS] */ /* detect the system type, AES + kernel */ #define SYS_TOS 0x0001 @@ -23,16 +27,34 @@ #define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */ extern unsigned short _systype_v; - -/* - Utils -*/ unsigned short _systype (void); OBJECT *get_tree( int idx ); -/* -* MultiTOS Drag&Drop -*/ +#ifndef POINT_WITHIN +# define POINT_WITHIN(_x,_y, r) ((_x >= r.g_x) && (_x <= r.g_x + r.g_w ) \ + && (_y >= r.g_y) && (_y <= r.g_y + r.g_h)) +#endif + +#ifndef RC_WITHIN +# define RC_WITHIN(a,b) \ + (((a)->g_x >= (b)->g_x) \ + && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \ + && (((a)->g_y >= (b)->g_y) \ + && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h))) +#endif + +#ifndef MAX +# define MAX(_a,_b) ((_a>_b) ? _a : _b) +#endif + +#ifndef MIN +# define MIN(_a,_b) ((_a<_b) ? _a : _b) +#endif + + +/* -------------------------------------------------------------------------- */ +/* MultiTOS Drag & Drop */ +/* -------------------------------------------------------------------------- */ short ddcreate(short *pipe); short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename); short ddrexts(short fd, char *exts); @@ -45,17 +67,17 @@ short ddsexts(short fd, char *exts); short ddrtry(short fd, char *name, char *file, char *whichext, long *size); short ddreply(short fd, char ack); -/* - Message box -*/ +/* -------------------------------------------------------------------------- */ +/* Message Box module */ +/* -------------------------------------------------------------------------- */ #define MSG_BOX_ALERT 1 #define MSG_BOX_CONFIRM 2 short msg_box_show(short type, const char * msg); -/* - Guiwin -*/ +/* -------------------------------------------------------------------------- */ +/* GUIWIN Module */ +/* -------------------------------------------------------------------------- */ #define GW_FLAG_PREPROC_WM 0x01 // let guiwin API handle some events #define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed #define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical @@ -120,29 +142,12 @@ bool guiwin_has_intersection(GUIWIN *win, GRECT *work); void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip); void guiwin_clear(GUIWIN *win); -/* -* AES Scroller Object -*/ - -#ifndef POINT_WITHIN -#define POINT_WITHIN(_x,_y, r) ((_x >= r.g_x) && (_x <= r.g_x + r.g_w ) \ - && (_y >= r.g_y) && (_y <= r.g_y + r.g_h)) -#endif - -#ifndef RC_WITHIN -#define RC_WITHIN(a,b) \ - (((a)->g_x >= (b)->g_x) \ - && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \ - && (((a)->g_y >= (b)->g_y) \ - && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h))) -#endif - -#ifndef MAX -#define MAX(_a,_b) ((_a>_b) ? _a : _b) -#endif +/* -------------------------------------------------------------------------- */ +/* AES Scroller module */ +/* -------------------------------------------------------------------------- */ -#ifndef MIN -#define MIN(_a,_b) ((_a<_b) ? _a : _b) -#endif +/* -------------------------------------------------------------------------- */ +/* AES Tabs module */ +/* -------------------------------------------------------------------------- */ #endif // GEMTK_H_INCLUDED diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c index e587b97d1..6e8cfa29d 100644 --- a/atari/gemtk/guiwin.c +++ b/atari/gemtk/guiwin.c @@ -1,4 +1,20 @@ -//#include "global.h" +/* + * Copyright 2012 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 <stdint.h> #include <stdbool.h> @@ -10,8 +26,8 @@ #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; @@ -170,13 +186,20 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8]) case WM_SIZED: case WM_REPOSED: + wind_get_grect(gw->handle, WF_FULLXYWH, &g2); wind_get_grect(gw->handle, WF_CURRXYWH, &g); - wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]); - if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) { - if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)) { - guiwin_send_redraw(gw, NULL); - } + 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); + } + } } + + break; case WM_FULLED: @@ -315,7 +338,7 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) 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) == 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); |