diff options
-rw-r--r-- | atari/gemtk/gemtk.h | 27 | ||||
-rw-r--r-- | atari/gemtk/guiwin.c | 390 | ||||
-rwxr-xr-x | atari/gui.c | 87 | ||||
-rwxr-xr-x | atari/history.c | 56 | ||||
-rwxr-xr-x | atari/hotlist.c | 86 | ||||
-rwxr-xr-x | atari/hotlist.h | 3 | ||||
-rwxr-xr-x | atari/rootwin.c | 8 | ||||
-rwxr-xr-x | atari/treeview.c | 203 | ||||
-rwxr-xr-x | atari/treeview.h | 12 |
9 files changed, 560 insertions, 312 deletions
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h index 1ac8935d7..5e0f5c464 100644 --- a/atari/gemtk/gemtk.h +++ b/atari/gemtk/gemtk.h @@ -59,27 +59,36 @@ short msg_box_show(short type, const char * msg); #define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed #define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical #define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling +#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling #define GW_STATUS_ICONIFIED 0x01 #define GW_STATUS_SHADED 0x02 struct gui_window_s; typedef struct gui_window_s GUIWIN; - typedef short (*guiwin_event_handler_f)(GUIWIN *gw, EVMULT_OUT *ev_out, short msg[8]); +struct guiwin_scroll_info_s { + int x_unit_px; + int y_unit_px; + int x_pos; + int y_pos; + int x_pos_max; + int y_pos_max; +}; + enum guwin_area_e { GUIWIN_AREA_WORK = 0, GUIWIN_AREA_TOOLBAR, GUIWIN_AREA_CONTENT }; +short guiwin_init(void); GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f handler); GUIWIN *guiwin_find(short handle); short guiwin_remove(GUIWIN *win); GUIWIN *guiwin_validate_ptr(GUIWIN *win); -//short guiwin_set_event_handler(guiwin_event_handler_f); short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]); void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest); @@ -87,6 +96,13 @@ short guiwin_get_handle(GUIWIN *win); uint32_t guiwin_get_state(GUIWIN *win); void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags); +void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb); +void guiwin_set_user_data(GUIWIN *win, void *data); +void *guiwin_get_user_data(GUIWIN *win); +struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win); +void guiwin_update_slider(GUIWIN *win, short mode); +VdiHdl guiwin_get_vdi_handle(GUIWIN *win); + /* * AES Scroller Object @@ -97,5 +113,12 @@ void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, && (_y >= r.g_y) && (_y <= r.g_y + r.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 #endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c index 56a306434..fa496bf6b 100644 --- a/atari/gemtk/guiwin.c +++ b/atari/gemtk/guiwin.c @@ -1,6 +1,7 @@ //#include "global.h" #include <stdint.h> +#include <stdbool.h> #include <assert.h> #include <cflib.h> @@ -11,24 +12,80 @@ #define DEBUG_PRINT(x) struct gui_window_s { - short handle; - guiwin_event_handler_f handler_func; - uint32_t flags; - uint32_t state; - OBJECT * toolbar; - short toolbar_idx; - struct gui_window_s *next, *prev; + short handle; + guiwin_event_handler_f handler_func; + uint32_t flags; + uint32_t state; + OBJECT * toolbar; + short toolbar_idx; + struct guiwin_scroll_info_s scroll_info; + void *user_data; + struct gui_window_s *next, *prev; }; static GUIWIN * winlist; +static VdiHdl v_vdi_h = -1; +static short work_out[57]; static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8]) { GRECT g, tb_area, tb_area_ro; short retval = 1; + int val; + struct guiwin_scroll_info_s *slid; switch(msg[0]) { + case WM_ARROWED: + if((gw->flag & GW_FLAG_CUSTOM_SCROLLING) == 0){ + + slid = guiwin_get_scroll_info(win); + + switch(msg[4]){ + case WA_DNPAGE: + guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &g); + val = g.g_h; + // complete redraw + // increase scroll val by page size... + break; + + case WA_UPLINE: + slid->g_y = MAX(0, slid->g_y-1); + // partial redraw + break; + + case WA_DNLINE: + slid->g_y = MIN(slid->y_pos_max, slid->g_y+1); + // move content up by unit size and sched redraw for the + // bottom 16 px + // partial redraw + break; + + case WA_LFPAGE: + // complete redraw + // increase scroll val by page size... + break; + + case WA_RTPAGE: + // complete redraw + // increase scroll val by page size... + break; + + case WA_LFLINE: + slid->g_x = MAX(0, slid->g_x-1); + // partial redraw + break; + + case WA_RTLINE: + slid->g_x = MIN(slid->x_pos_max, slid->g_x+1); + // partial redraw + break; + + default: break; + } + } + break; + case WM_TOPPED: wind_set(gw->handle, WF_TOP, 1, 0, 0, 0); break; @@ -38,56 +95,56 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8]) wind_set(gw->handle, WF_CURRXYWH, msg[4], msg[5], g.g_w, g.g_h); break; - case WM_SIZED: + case WM_SIZED: case WM_REPOSED: - wind_get_grect(gw->handle, WF_CURRXYWH, &g); - wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]); - break; + wind_get_grect(gw->handle, WF_CURRXYWH, &g); + wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]); + break; - case WM_FULLED: - wind_get_grect(0, WF_WORKXYWH, &g); - wind_set_grect(gw->handle, WF_CURRXYWH, &g); - break; + case WM_FULLED: + wind_get_grect(gw->handle, WF_FULLXYWH, &g); + wind_set_grect(gw->handle, WF_CURRXYWH, &g); + break; - case WM_ICONIFY: - wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]); - gw->state |= GW_STATUS_ICONIFIED; - break; + case WM_ICONIFY: + wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]); + gw->state |= GW_STATUS_ICONIFIED; + break; - case WM_UNICONIFY: - wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]); - gw->state &= ~(GW_STATUS_ICONIFIED); - break; + case WM_UNICONIFY: + wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]); + gw->state &= ~(GW_STATUS_ICONIFIED); + break; - case WM_SHADED: - gw->state |= GW_STATUS_SHADED; - break; + case WM_SHADED: + gw->state |= GW_STATUS_SHADED; + break; - case WM_UNSHADED: - gw->state &= ~(GW_STATUS_SHADED); - break; + case WM_UNSHADED: + gw->state &= ~(GW_STATUS_SHADED); + break; - case WM_REDRAW: - if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) { - guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro); - tb_area = tb_area_ro; - if(rc_intersect((GRECT*)&msg[4], &tb_area)){ - wind_get_grect(gw->handle, WF_FIRSTXYWH, &g); - while (g.g_h > 0 || g.g_w > 0) { - gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x; - gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w; - gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y; - gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h; - objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y, - g.g_w, g.g_h); - wind_get_grect(gw->handle, WF_NEXTXYWH, &g); - } - } - } - break; + case WM_REDRAW: + if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) { + guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro); + tb_area = tb_area_ro; + if(rc_intersect((GRECT*)&msg[4], &tb_area)) { + wind_get_grect(gw->handle, WF_FIRSTXYWH, &g); + while (g.g_h > 0 || g.g_w > 0) { + gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x; + gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w; + gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y; + gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h; + objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y, + g.g_w, g.g_h); + wind_get_grect(gw->handle, WF_NEXTXYWH, &g); + } + } + } + break; default: - retval = 0; + retval = 0; break; } return(retval); @@ -100,8 +157,8 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) if( (ev_out->emo_events & MU_MESAG) != 0 ) { DEBUG_PRINT(("guiwin_handle_event_multi_fast: %d\n", msg[0])); - switch (msg[0]) { - case WM_REDRAW: + switch (msg[0]) { + case WM_REDRAW: case WM_CLOSED: case WM_TOPPED: case WM_ARROWED: @@ -128,62 +185,88 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) if (dest->flags&GW_FLAG_PREPROC_WM) { retval = preproc_wm(dest, ev_out, msg); if(((retval == 0)||(dest->flags&GW_FLAG_RECV_PREPROC_WM))) { - retval = dest->handler_func(dest, ev_out, msg); + retval = dest->handler_func(dest, ev_out, msg); + } + } else { + if (dest->handler_func) { + retval = dest->handler_func(dest, ev_out, msg); } - } - else { - if (dest->handler_func) { - retval = dest->handler_func(dest, ev_out, msg); - } } } break; } - } - if( (ev_out->emo_events & MU_BUTTON) != 0){ - short info[4]; + } else { + + short info[4]; + wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]); + + if(info[0] != 0 && info[1] == gl_apid) { - wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]); - if(info[0] != 0 && info[1] == gl_apid){ - dest = guiwin_find(info[0]); - if (dest) { + dest = guiwin_find(info[0]); + + 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)); - // toolbar handling: - if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 && - dest->toolbar != NULL && dest->handler_func != 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); - short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle, - obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0}; - short oldevents = ev_out->emo_events; - ev_out->emo_events = MU_MESAG; - dest->handler_func(dest, ev_out, msg_out); - ev_out->emo_events = oldevents; - retval = 1; - } - } + // 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); + short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle, + obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0 + }; + short oldevents = ev_out->emo_events; + ev_out->emo_events = MU_MESAG; + dest->handler_func(dest, ev_out, msg_out); + ev_out->emo_events = oldevents; + retval = 1; + } else { + dest->handler_func(dest, ev_out, msg); + } + } + } else if(ev_out->emo_events & MU_KEYBD) { + dest->handler_func(dest, ev_out, msg); } - } + } } + return(retval); } +short guiwin_init(void) +{ + if(v_vdi_h == -1){ + short dummy; + static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1}; + v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy); + v_opnvwk(work_in, &v_vdi_h, work_out); + } +} + +void guiwin_exit(void) +{ + v_clsvwk(v_vdi_h); +} + GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb) { + GUIWIN *win = calloc(sizeof(GUIWIN),1); - assert(win!=NULL); + assert(win!=NULL); DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb)); win->handle = handle; @@ -221,8 +304,8 @@ GUIWIN *guiwin_find(short handle) GUIWIN *guiwin_validate_ptr(GUIWIN *win) { - GUIWIN *g; - for( g = winlist; g != NULL; g=g->next ) { + GUIWIN *g; + for( g = winlist; g != NULL; g=g->next ) { DEBUG_PRINT(("guiwin guiwin_validate_ptr check: %p\n", g)); if(g == win) { DEBUG_PRINT(("guiwin_validate_ptr valid: %p\n", g)); @@ -234,8 +317,8 @@ GUIWIN *guiwin_validate_ptr(GUIWIN *win) short guiwin_remove(GUIWIN *win) { - win = guiwin_validate_ptr(win); - if (win == NULL) + win = guiwin_validate_ptr(win); + if (win == NULL) return(-1); /* unlink the window: */ @@ -254,49 +337,110 @@ short guiwin_remove(GUIWIN *win) void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest) { - wind_get_grect(win->handle, WF_WORKXYWH, dest); - if (mode == GUIWIN_AREA_CONTENT) { - GRECT tb_area; - guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area); - if (win->flags & GW_FLAG_HAS_VTOOLBAR) { - dest->g_x += tb_area.g_w; - dest->g_w -= tb_area.g_w; - } else { - dest->g_y += tb_area.g_h; - dest->g_h -= tb_area.g_h; - } - } - else if (mode == GUIWIN_AREA_TOOLBAR) { - if (win->toolbar != NULL) { - if (win->flags & GW_FLAG_HAS_VTOOLBAR) { - dest->g_w = win->toolbar[win->toolbar_idx].ob_width; - } else { - dest->g_h = win->toolbar[win->toolbar_idx].ob_height; - } - } else { - dest->g_h = 0; - dest->g_w = 0; - } - } + wind_get_grect(win->handle, WF_WORKXYWH, dest); + if (mode == GUIWIN_AREA_CONTENT) { + GRECT tb_area; + guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area); + if (win->flags & GW_FLAG_HAS_VTOOLBAR) { + dest->g_x += tb_area.g_w; + dest->g_w -= tb_area.g_w; + } else { + dest->g_y += tb_area.g_h; + dest->g_h -= tb_area.g_h; + } + } else if (mode == GUIWIN_AREA_TOOLBAR) { + if (win->toolbar != NULL) { + if (win->flags & GW_FLAG_HAS_VTOOLBAR) { + dest->g_w = win->toolbar[win->toolbar_idx].ob_width; + } else { + dest->g_h = win->toolbar[win->toolbar_idx].ob_height; + } + } else { + dest->g_h = 0; + dest->g_w = 0; + } + } +} + +void guiwin_update_slider(GUIWIN *win, short mode) +{ + GRECT viewport; + struct guiwin_scroll_info_s * slid; + unsigned long size, pos; + + short handle = guiwin_get_handle(win); + guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport); + slid = guiwin_get_scroll_info(win); + + if((mode & 1) && (slid->y_unit_px > 0)) { + if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px) + size = 1000L; + else + size = MAX( 50L, (unsigned long)viewport.g_h*1000L/(unsigned long)(slid->y_unit_px*slid->y_pos_max)); + wind_set(handle, WF_VSLSIZE, (int)size, 0, 0, 0); + + if (slid->y_pos_max > (long)viewport.g_h/slid->y_unit_px) { + pos = (unsigned long)slid->y_pos *1000L/(unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px); + wind_set(handle, WF_VSLIDE, (int)pos, 0, 0, 0); + } else if (slid->y_pos) { + slid->y_pos = 0; + wind_set(handle, WF_VSLIDE, 0, 0, 0, 0); + } + } + if((mode & 2) && (slid->x_unit_px > 0)) { + if ( slid->x_pos_max < (long)viewport.g_w/slid->x_unit_px) + size = 1000L; + else + size = MAX( 50L, (unsigned long)viewport.g_w*1000L/(unsigned long)(slid->x_unit_px*slid->x_pos_max)); + wind_set(handle, WF_HSLSIZE, (int)size, 0, 0, 0); + + if( slid->x_pos_max > (long)viewport.g_w/slid->x_unit_px) { + pos = (unsigned long)slid->x_pos*1000L/(unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px); + wind_set(handle, WF_HSLIDE, (int)pos, 0, 0, 0); + } else if (slid->x_pos) { + slid->x_pos = 0; + wind_set(handle, WF_HSLIDE, 0, 0, 0, 0); + } + } } short guiwin_get_handle(GUIWIN *win) { - return(win->handle); + return(win->handle); } uint32_t guiwin_get_state(GUIWIN *win) { - return(win->state); + return(win->state); +} + +void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb) +{ + win->handler_func = cb; } void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags) { - win->toolbar = toolbar; - win->toolbar_idx = idx; - if(flags & GW_FLAG_HAS_VTOOLBAR){ - win->flags |= GW_FLAG_HAS_VTOOLBAR; - } + win->toolbar = toolbar; + win->toolbar_idx = idx; + if(flags & GW_FLAG_HAS_VTOOLBAR) { + win->flags |= GW_FLAG_HAS_VTOOLBAR; + } +} + +void guiwin_set_user_data(GUIWIN *win, void *data) +{ + win->user_data = data; +} + +void *guiwin_get_user_data(GUIWIN *win) +{ + return(win->user_data); +} + +struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) +{ + return(&win->scroll_info); } diff --git a/atari/gui.c b/atari/gui.c index 4f7a97b9f..fb412f376 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -86,6 +86,7 @@ struct gui_window *window_list = NULL; void * h_gem_rsrc; long next_poll; bool rendering = false; +bool gui_poll_repeat = false; /* Comandline / Options: */ @@ -162,44 +163,48 @@ void gui_poll(bool active) short mx, my, dummy; unsigned short nkc = 0; - evnt.timer = schedule_run(); - - if(active || rendering) { - if (clock() >= next_poll) { - aes_event_in.emi_tlow = 0; - evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); - next_poll = clock() + (CLOCKS_PER_SEC>>4); - } - } else { - evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); - } + gui_poll_repeat = false; - if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) { - //global_dispatch_event(&aes_event_in, &aes_event_out, msg); - if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { - LOG(("WM: %d\n", aes_msg_out[0])); - switch(aes_msg_out[0]) { - - case MN_SELECTED: - LOG(("Menu Item: %d\n",aes_msg_out[4])); - deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); - break; - - default: - break; - } - } + evnt.timer = schedule_run(); - if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) { - printf("key: %d, %d\n", aes_event_out.emo_kreturn, - aes_event_out.emo_kmeta); - nkc= gem_to_norm( (short)aes_event_out.emo_kmeta, - (short)aes_event_out.emo_kreturn); - deskmenu_dispatch_keypress(aes_event_out.emo_kreturn, - aes_event_out.emo_kmeta, nkc); + if(active || rendering) + aes_event_in.emi_tlow = 0; + + // Handle events until there are no more messages pending or + // until the engine indicates activity: + do { + evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); + if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) { + if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { + LOG(("WM: %d\n", aes_msg_out[0])); + switch(aes_msg_out[0]) { + + case MN_SELECTED: + LOG(("Menu Item: %d\n",aes_msg_out[4])); + deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); + break; + default: + break; + } + } + + if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) { + printf("key: %d, %d\n", aes_event_out.emo_kreturn, + aes_event_out.emo_kmeta); + nkc= gem_to_norm( (short)aes_event_out.emo_kmeta, + (short)aes_event_out.emo_kreturn); + deskmenu_dispatch_keypress(aes_event_out.emo_kreturn, + aes_event_out.emo_kmeta, nkc); + } } - } + } while ( gui_poll_repeat && !(active||rendering)); + if( !active ) { + /* this suits for stuff with lower priority */ + /* TBD: really be spare on redraws??? */ + hotlist_redraw(); + //global_history_redraw(); + } } void gui_poll_old(bool active) @@ -374,7 +379,7 @@ void gui_window_set_status(struct gui_window *w, const char *text) { if (w == NULL || text == NULL ) return; - window_set_stauts( w , (char*)text ); + window_set_stauts(w, (char*)text ); } void gui_window_redraw_window(struct gui_window *gw) @@ -905,6 +910,7 @@ void gui_quit(void) urldb_save(nsoption_charp(url_file)); deskmenu_destroy(); + guiwin_exit(); rsrc_free(); @@ -1032,14 +1038,6 @@ static void gui_init(int argc, char** argv) if (rsrc_load(buf)==0) { die("Uable to open GEM Resource file!"); } - //h_gem_rsrc = RsrcXload( (char*) &buf ); - - //if( !h_gem_rsrc ) - // die("Uable to open GEM Resource file!"); - //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex; - //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree; - - //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree); create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand ); create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam ); @@ -1049,7 +1047,7 @@ static void gui_init(int argc, char** argv) create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall); create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw); create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse); - RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors ); + cursors = get_tree(CURSOR); create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART, cursors, &gem_cursors.appstarting); gem_set_cursor( &gem_cursors.appstarting ); @@ -1095,6 +1093,7 @@ static void gui_init2(int argc, char** argv) if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) { menu_register( _AESapid, (char*)" NetSurf "); } + guiwin_init(); bind_global_events(); global_history_init(); hotlist_init(); diff --git a/atari/history.c b/atari/history.c index ad5deb2bd..0df7ec476 100755 --- a/atari/history.c +++ b/atari/history.c @@ -86,33 +86,35 @@ static void __CDECL evnt_history_mbutton( WINDOW *win, short buff[8] ) bool global_history_init( void ) { - if( gl_history.init == false ) { - - int flags = ATARI_TREEVIEW_WIDGETS; - gl_history.open = false; - gl_history.window = WindCreate( flags, 40, 40, app.w, app.h ); - if( gl_history.window == NULL ) { - LOG(("Failed to allocate history window")); - return( false ); - } - WindSetStr(gl_history.window, WF_NAME, messages_get("GlobalHistory")); - //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar ); - EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close ); - EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton ); - - gl_history.tv = atari_treeview_create( - history_global_get_tree_flags(), - gl_history.window - ); - if (gl_history.tv == NULL) { - /* handle it properly, clean up previous allocs */ - LOG(("Failed to allocate history treeview")); - return( false ); - } - - history_global_initialise( gl_history.tv->tree, "dir.png" ); - gl_history.init = true; - } + return(true); +// if( gl_history.init == false ) { +// +// int flags = ATARI_TREEVIEW_WIDGETS; +// gl_history.open = false; +// gl_history.window = WindCreate( flags, 40, 40, app.w, app.h ); +// if( gl_history.window == NULL ) { +// LOG(("Failed to allocate history window")); +// return( false ); +// } +// WindSetStr(gl_history.window, WF_NAME, messages_get("GlobalHistory")); +// //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar ); +// EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close ); +// EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton ); +// +// gl_history.tv = atari_treeview_create( +// history_global_get_tree_flags(), +// gl_history.window, +// NULL +// ); +// if (gl_history.tv == NULL) { +// /* handle it properly, clean up previous allocs */ +// LOG(("Failed to allocate history treeview")); +// return( false ); +// } +// +// history_global_initialise( gl_history.tv->tree, "dir.png" ); +// gl_history.init = true; +// } return( true ); } diff --git a/atari/hotlist.c b/atari/hotlist.c index 5d54d061b..7fbac3e7f 100755 --- a/atari/hotlist.c +++ b/atari/hotlist.c @@ -22,6 +22,9 @@ #include <stdio.h> #include <stdlib.h> #include <time.h> + +#include <windom.h> + #include "desktop/browser.h" #include "content/content.h" #include "content/hlcache.h" @@ -45,45 +48,48 @@ struct atari_hotlist hl; -static void evnt_hl_toolbar( WINDOW *win, short buff[8]) { - /* handle toolbar object (index in buff[4] ) */ - switch( buff[4] ) { - case TOOLBAR_HOTLIST_CREATE_FOLDER: - hotlist_add_folder(true); - break; - - case TOOLBAR_HOTLIST_ADD: - atari_hotlist_add_page("http://www.de", ""); - break; +static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) +{ - case TOOLBAR_HOTLIST_DELETE: - hotlist_delete_selected(); - break; + printf("hotlist handle event...\n"); + if(ev_out->emo_events & MU_MESAG){ + switch (msg[0]) { + case WM_TOOLBAR: + printf("toolbar event...%d\n", msg[4]); + switch (msg[4]) { - case TOOLBAR_HOTLIST_EDIT: - hotlist_edit_selected(); - break; - } - ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG ); -} + case TOOLBAR_HOTLIST_CREATE_FOLDER: + hotlist_add_folder(true); + break; + case TOOLBAR_HOTLIST_ADD: + atari_hotlist_add_page("http://www.de", ""); + break; -static void __CDECL evnt_hl_close( WINDOW *win, short buff[8] ) -{ - hotlist_close(); -} + case TOOLBAR_HOTLIST_DELETE: + hotlist_delete_selected(); + break; + case TOOLBAR_HOTLIST_EDIT: + hotlist_edit_selected(); + break; + } + break; -static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] ) -{ - /* todo: implement popup? - if(evnt.mbut & 2) { + case WM_CLOSED: + hotlist_close(); + break; + default: break; + } } - */ + + // TODO: implement selectable objects in toolbar API: + // ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG ); } + void hotlist_init(void) { if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){ @@ -96,21 +102,24 @@ void hotlist_init(void) if( hl.window == NULL ){ int flags = ATARI_TREEVIEW_WIDGETS; + short handle = -1; OBJECT * tree = get_tree(TOOLBAR_HOTLIST); assert( tree ); hl.open = false; - hl.window = WindCreate( flags, 40, 40, app.w, app.h ); + handle = wind_create(flags, 0, 0, app.w, app.h); + hl.window = guiwin_add(handle, + GW_FLAG_PREPROC_WM|GW_FLAG_RECV_PREPROC_WM, + NULL); if( hl.window == NULL ) { LOG(("Failed to allocate Hotlist")); return; } - WindSetStr( hl.window, WF_NAME, (char*)messages_get("Hotlist") ); - WindSetPtr( hl.window, WF_TOOLBAR, tree, evnt_hl_toolbar ); - EvntAttach( hl.window, WM_CLOSED, evnt_hl_close ); - EvntAttach( hl.window, WM_XBUTTON,evnt_hl_mbutton ); + wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist")); + guiwin_set_toolbar(hl.window, tree, 0, 0); hl.tv = atari_treeview_create( hotlist_get_tree_flags(), - hl.window + hl.window, + handle_event ); if (hl.tv == NULL) { /* handle it properly, clean up previous allocs */ @@ -140,17 +149,17 @@ void hotlist_open(void) } if( hl.open == false ) { - WindOpen( hl.window, pos.g_x, pos.g_y, pos.g_w, pos.g_h); + wind_open_grect(guiwin_get_handle(hl.window), &pos); hl.open = true; atari_treeview_open( hl.tv ); } else { - WindTop( hl.window ); + wind_set(guiwin_get_handle(hl.window), WF_TOP, 1, 0, 0, 0); } } void hotlist_close(void) { - WindClose(hl.window); + wind_close(guiwin_get_handle(hl.window)); hl.open = false; atari_treeview_close( hl.tv ); } @@ -164,7 +173,8 @@ void hotlist_destroy(void) hotlist_cleanup( (char*)&hl.path ); if( hl.open ) hotlist_close(); - WindDelete( hl.window ); + wind_delete(guiwin_get_handle(hl.window)); + guiwin_remove(hl.window); hl.window = NULL; atari_treeview_destroy( hl.tv ); hl.init = false; diff --git a/atari/hotlist.h b/atari/hotlist.h index 70b4d8a70..858d1a1bf 100755 --- a/atari/hotlist.h +++ b/atari/hotlist.h @@ -21,11 +21,12 @@ #include <stdbool.h>
#include <windom.h>
#include "desktop/tree.h"
+#include "atari/gemtk/gemtk.h" #include "atari/treeview.h"
/* The hotlist window, toolbar and treeview data. */
struct atari_hotlist {
- WINDOW * window;
+ GUIWIN * window;
NSTREEVIEW tv; /*< The hotlist treeview handle. */
bool open;
bool init;
diff --git a/atari/rootwin.c b/atari/rootwin.c index a05c66e09..aff910c78 100755 --- a/atari/rootwin.c +++ b/atari/rootwin.c @@ -122,7 +122,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_CLOSED: gw = FIND_NS_GUI_WINDOW(win); if( gw != NULL ) { - browser_window_destroy( gw->browser->bw ); + browser_window_destroy(gw->browser->bw ); } break; @@ -158,9 +158,9 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) } -int window_create( struct gui_window * gw, +int window_create(struct gui_window * gw, struct browser_window * bw, - unsigned long inflags ) + unsigned long inflags) { int err = 0; bool tb, sb; @@ -343,7 +343,7 @@ void window_set_stauts(struct gui_window * gw , char * text ) } /* set focus to an arbitary element */ -void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element ) +void window_set_focus(struct gui_window * gw, enum focus_element_type type, void * element) { if( gw->root->focus.type != type || gw->root->focus.element != element ) { LOG(("Set focus: %p (%d)\n", element, type)); diff --git a/atari/treeview.c b/atari/treeview.c index 6e567f569..ab0afb515 100755 --- a/atari/treeview.c +++ b/atari/treeview.c @@ -21,7 +21,6 @@ #include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <windom.h>
#include "content/urldb.h"
#include "desktop/browser.h"
@@ -36,15 +35,10 @@ #include "atari/gui.h"
#include "atari/treeview.h"
#include "atari/plot/plot.h"
-#include "atari/misc.h"
+#include "atari/misc.h" +#include "atari/gemtk/gemtk.h"
#include "cflib.h" -/* -#define TREEVIEW_RECT_WORKAREA 0 -#define TREEVIEW_RECT_TOOLBAR 1 -#define TREEVIEW_RECT_CONTENT 2 -*/ - enum treeview_area_e { TREEVIEW_AREA_WORK = 0, TREEVIEW_AREA_TOOLBAR, @@ -69,9 +63,58 @@ static const struct treeview_table atari_tree_callbacks = { 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) guiwin_get_user_data(win); + + if( (ev_out->emo_events & MU_MESAG) != 0 ) { + // handle message + printf("treeview msg: %d\n", msg[0]); + switch (msg[0]) { + + case WM_REDRAW: + on_redraw_event(tv, ev_out, msg); + break; + + default: + break; + } + } + if( (ev_out->emo_events & MU_KEYBD) != 0 ) { + printf("Treeview keybd\n"); + on_keybd_event(tv, ev_out, msg); + // handle key + } + if( (ev_out->emo_events & MU_TIMER) != 0 ) { + // handle_timer(); + } + 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)); + printf("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 evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out, + short msg[8])
{
bool r=false;
long kstate = 0;
@@ -82,9 +125,8 @@ static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data ) unsigned short nks = 0;
unsigned char ascii;
- NSTREEVIEW tv = (NSTREEVIEW) data;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
+ 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 );
@@ -99,15 +141,18 @@ static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data ) }
-static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out, + short msg[8])
{
GRECT work, clip;
- NSTREEVIEW tv = (NSTREEVIEW) data;
+ if( tv == NULL )
return;
- WindGetGrect( win, WF_WORKXYWH, &work );
+ + guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work); +
clip = work;
- if ( !rc_intersect( (GRECT*)&buff[4], &clip ) ) return;
+ 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 ) {
@@ -118,31 +163,37 @@ static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data ) clip.g_h = work.g_h + clip.g_y;
clip.g_y = 0;
}
- if( clip.g_h > 0 && clip.g_w > 0 ) {
+ if( clip.g_h > 0 && clip.g_w > 0 ) { + // TODO: get slider values
atari_treeview_request_redraw(
- win->xpos*win->w_u + clip.g_x,
- win->ypos*win->h_u + clip.g_y,
+ /*win->xpos*win->w_u +*/ clip.g_x,
+ /*win->ypos*win->h_u +*/ clip.g_y,
clip.g_w, clip.g_h, tv
);
}
}
-static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out, + short msg[8])
{
GRECT work;
- NSTREEVIEW tv = (NSTREEVIEW) data;
- if( tv == NULL )
+ if(tv == NULL)
return;
if( evnt.mbut & 2 ) {
/* do not handle right click */
return;
- }
+ } + + guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
+ /* mouse click relative origin: */ - WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ // TODO: get scroll position + //short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
+ //short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u); - /* mouse click relative origin: */
- short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
- short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
+ short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x);
+ short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y); if( origin_rel_x >= 0 && origin_rel_y >= 0
&& evnt.mx < work.g_x + work.g_w
@@ -199,9 +250,10 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data ) 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)+(win->xpos*win->w_u);
- cur_rel_y = (cur_rel_y-work.g_y)+(win->ypos*win->h_u);
+ graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy); + // TODO : get guwin slider values;
+ cur_rel_x = (cur_rel_x-work.g_x)/*+(win->xpos*win->w_u);*/;
+ cur_rel_y = (cur_rel_y-work.g_y)/*+(win->ypos*win->h_u);*/;
} while( mbut & 1 );
tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
@@ -211,8 +263,11 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data ) }
}
-NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
-{
+NSTREEVIEW atari_treeview_create(uint32_t flags, GUIWIN *win, + guiwin_event_handler_f user_func)
+{ + struct guiwin_scroll_info_s *slid; +
if( win == NULL )
return( NULL );
NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
@@ -224,15 +279,16 @@ NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win ) free(new);
return NULL;
}
- new->window = win;
-
- win->w_u = 16;
- win->h_u = 16;
-
- EvntDataAdd( new->window, WM_XBUTTON, evnt_tv_mbutton, new, EV_BOT );
- EvntDataAttach( new->window, WM_REDRAW, evnt_tv_redraw, new );
- EvntDataAttach( new->window, WM_XKEYBD, evnt_tv_keybd, new );
+ new->window = win; + new->user_func = user_func; + + guiwin_set_event_handler(win, handle_event); + guiwin_set_user_data(win, (void*)new); + slid = guiwin_get_scroll_info(new->window); + slid->y_unit_px = 16; + slid->x_unit_px = 16;
+ return(new);
}
@@ -265,15 +321,25 @@ void atari_treeview_destroy( NSTREEVIEW tv ) bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
{
+ GRECT work; + if( tv == NULL )
return ( false );
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
- int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
- int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
- tree_mouse_action(tv->tree, bms, rx, ry );
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work); +
+ //int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
+ //int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
+ + // TODO: get slider values + int rx = (x-work.g_x);
+ int ry = (y-work.g_y); + + tree_mouse_action(tv->tree, bms, rx, ry); +
tv->click.x = rx;
tv->click.y = ry;
+ return( true );
}
@@ -284,9 +350,12 @@ void atari_treeview_redraw( NSTREEVIEW tv) if (tv != NULL) {
if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
+ short todo[4];
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ GRECT work; + short handle = guiwin_get_handle(tv->window);
+ + guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
struct redraw_context ctx = {
.interactive = true,
@@ -303,13 +372,14 @@ void atari_treeview_redraw( NSTREEVIEW tv) todo[3] = todo[1] + work.g_h-1;
vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
- if( wind_get(tv->window->handle, WF_FIRSTXYWH,
+ if( wind_get(handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
- /* convert screen to treeview coords: */
- todo[0] = todo[0] - work.g_x + tv->window->xpos*tv->window->w_u;
- todo[1] = todo[1] - work.g_y + tv->window->ypos*tv->window->h_u;
+ /* convert screen to treeview coords: */ + // TODO: get slider values:
+ todo[0] = todo[0] - work.g_x;/*+ tv->window->xpos*tv->window->w_u;*/
+ todo[1] = todo[1] - work.g_y;/*+ tv->window->ypos*tv->window->h_u;*/
if( todo[0] < 0 ){
todo[2] = todo[2] + todo[0];
todo[0] = 0;
@@ -318,13 +388,15 @@ void atari_treeview_redraw( NSTREEVIEW tv) 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, -tv->window->xpos*16, -tv->window->ypos*16,
+ tree_draw(tv->tree, 0/*-tv->window->xpos*16*/, + 0 /*-tv->window->ypos*16*/,
todo[0], todo[1], todo[2], todo[3], &ctx
);
}
- if (wind_get(tv->window->handle, WF_NEXTXYWH,
+ if (wind_get(handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
@@ -396,11 +468,12 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw) NSTREEVIEW tv = (NSTREEVIEW) pw;
if( tv->disposing )
return;
- tv->extent.x = width;
- tv->extent.y = height;
- tv->window->ypos_max = (height / tv->window->w_u)+0.5;
- tv->window->xpos_max = (width / tv->window->h_u)+0.5;
- WindSlider( tv->window, HSLIDER|VSLIDER );
+ // TODO: update slider size + struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window); + slid->x_pos_max = (width / slid->x_unit_px); + slid->y_pos_max = (height / slid->y_unit_px); + printf("updating slider...\n"); + guiwin_update_slider(tv->window, 3);
}
}
@@ -423,17 +496,11 @@ static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode, GRECT *dest) { - wind_get_grect(tv->window->handle, WF_WORKXYWH, dest); if (mode == TREEVIEW_AREA_CONTENT) { - GRECT tb_grect; - atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_grect); - dest->g_y += tb_grect.g_h; - dest->g_h -= tb_grect.g_h; + guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, dest); } else if (mode == TREEVIEW_AREA_TOOLBAR) { - // TODO: this requires something like: - // guiwin_get_toolbar(); - dest->g_h = 16; + guiwin_get_grect(tv->window, GUIWIN_AREA_TOOLBAR, dest); } }
diff --git a/atari/treeview.h b/atari/treeview.h index 3796665af..41d1cf519 100755 --- a/atari/treeview.h +++ b/atari/treeview.h @@ -22,25 +22,27 @@ #include <stdbool.h>
#include <windom.h>
#include "desktop/tree.h"
-#include "atari/gui.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;
- WINDOW * window;
+ GUIWIN * window;
bool disposing;
bool redraw;
GRECT rdw_area;
POINT click;
- POINT extent;
- POINT startdrag;
+ POINT startdrag; + guiwin_event_handler_f user_func;
};
typedef struct atari_treeview * NSTREEVIEW;
-NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW * win );
+NSTREEVIEW atari_treeview_create( uint32_t flags, GUIWIN *win, + guiwin_event_handler_f user_func);
void atari_treeview_destroy( NSTREEVIEW tv );
void atari_treeview_open( NSTREEVIEW tv );
void atari_treeview_close( NSTREEVIEW tv );
|