Hotlist now works without windom.

This commit is contained in:
Ole Loots 2012-11-22 01:19:20 +01:00
parent 42cb583842
commit 407389668b
7 changed files with 95 additions and 70 deletions

View File

@ -62,6 +62,8 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM)
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
@ -78,8 +80,8 @@ struct guiwin_scroll_info_s {
int y_unit_px;
int x_pos;
int y_pos;
int x_pos_max;
int y_pos_max;
int x_units;
int y_units;
};
enum guwin_area_e {
@ -110,7 +112,7 @@ bool guiwin_update_slider(GUIWIN *win, short mode);
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 *gw, GRECT *clip);
/*

View File

@ -314,6 +314,7 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
{
GUIWIN *dest;
short retval = 0;
bool handler_called = false;
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
DEBUG_PRINT(("guiwin_handle_event_multi_fast: %d\n", msg[0]));
@ -346,10 +347,12 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
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);
handler_called = true;
}
} else {
if (dest->handler_func) {
retval = dest->handler_func(dest, ev_out, msg);
handler_called = true;
}
}
@ -396,13 +399,13 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
short oldevents = ev_out->emo_events;
ev_out->emo_events = MU_MESAG;
dest->handler_func(dest, ev_out, msg_out);
handler_called=true;
ev_out->emo_events = oldevents;
retval = 1;
} else {
dest->handler_func(dest, ev_out, msg);
}
}
} else if(ev_out->emo_events & MU_KEYBD) {
}
if (handler_called==false) {
dest->handler_func(dest, ev_out, msg);
}
}
@ -457,11 +460,10 @@ GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
GUIWIN *guiwin_find(short handle)
{
GUIWIN *g;
DEBUG_PRINT(("guiwin_find: handle: %d\n", handle));
DEBUG_PRINT(("guiwin search handle: %d\n", handle));
for( g = winlist; g != NULL; g=g->next ) {
DEBUG_PRINT(("guiwin search: %d\n", g->handle));
if(g->handle == handle) {
DEBUG_PRINT(("guiwin_find: %p\n", g));
DEBUG_PRINT(("guiwin found handle: %p\n", g));
return(g);
}
}
@ -496,7 +498,7 @@ short guiwin_remove(GUIWIN *win)
if (win->next != NULL) {
win->next->prev = win->prev;
}
DEBUG_PRINT(("guiwin free: %p\n", win));
free(win);
return(0);
}

View File

@ -165,7 +165,9 @@ void gui_poll(bool active)
gui_poll_repeat = false;
evnt.timer = schedule_run();
aes_event_in.emi_tlow = schedule_run();
//printf("time: ");
if(active || rendering)
aes_event_in.emi_tlow = 0;
@ -203,7 +205,7 @@ void gui_poll(bool active)
/* this suits for stuff with lower priority */
/* TBD: really be spare on redraws??? */
hotlist_redraw();
//global_history_redraw();
global_history_redraw();
}
}

View File

@ -45,76 +45,87 @@ struct s_atari_global_history gl_history;
void global_history_open( void )
{
GRECT pos = {app.w - (app.w/3), app.y, app.w/3, app.h/2};
if (gl_history.init == false ) {
printf("history not init");
return;
}
if( gl_history.open == false ) {
WindOpen( gl_history.window, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
GRECT pos;
wind_get_grect(0, WF_FULLXYWH, &pos);
pos.g_x = pos.g_w - pos.g_w / 4;
pos.g_y = pos.g_y;
pos.g_w = pos.g_w / 4;
pos.g_h = pos.g_h;
wind_open(guiwin_get_handle(gl_history.window), pos.g_x, pos.g_y,
pos.g_w, pos.g_h);
gl_history.open = true;
atari_treeview_open( gl_history.tv );
atari_treeview_open(gl_history.tv);
} else {
WindTop( gl_history.window );
wind_set(guiwin_get_handle(gl_history.window), WF_TOP, 1, 0, 0, 0);
}
}
void global_history_close( void )
{
WindClose(gl_history.window);
wind_close(guiwin_get_handle(gl_history.window));
gl_history.open = false;
atari_treeview_close( gl_history.tv );
atari_treeview_close(gl_history.tv);
}
static void __CDECL evnt_history_close( WINDOW *win, short buff[8] )
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
global_history_close();
}
NSTREEVIEW tv=NULL;
printf("Hotlist event %d, open: %d\n", ev_out->emo_events, gl_history.open);
static void __CDECL evnt_history_mbutton( WINDOW *win, short buff[8] )
{
/* todo: implement popup?
if(evnt.mbut & 2) {
if(ev_out->emo_events & MU_MESAG){
switch (msg[0]) {
case WM_CLOSED:
global_history_close();
break;
default: break;
}
}
*/
// TODO: implement selectable objects in toolbar API:
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
bool global_history_init( void )
{
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;
// }
if( gl_history.init == false ) {
short handle;
GRECT desk;
int flags = ATARI_TREEVIEW_WIDGETS;
wind_get_grect(0, WF_FULLXYWH, &desk);
gl_history.open = false;
handle = wind_create(flags, 40, 40, desk.g_w, desk.g_h);
gl_history.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
if( gl_history.window == NULL ) {
LOG(("Failed to allocate history window"));
return( false );
}
wind_set_str(handle, WF_NAME, (char*)messages_get("GlobalHistory"));
gl_history.tv = atari_treeview_create(history_global_get_tree_flags(),
gl_history.window, handle_event);
if (gl_history.tv == NULL) {
/* TODO: 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 );
}
@ -128,9 +139,10 @@ void global_history_destroy( void )
history_global_cleanup();
if( gl_history.open )
global_history_close();
WindDelete( gl_history.window );
wind_delete(guiwin_get_handle(gl_history.window));
guiwin_remove(gl_history.window);
gl_history.window = NULL;
atari_treeview_destroy( gl_history.tv );
atari_treeview_destroy(gl_history.tv);
gl_history.init = false;
}
LOG(("done"));

View File

@ -23,9 +23,10 @@
#include <windom.h>
#include "desktop/tree.h"
#include "atari/treeview.h"
#include "atari/gemtk/gemtk.h"
struct s_atari_global_history {
WINDOW * window;
GUIWIN *window; /*< The GEMTK window ref */
NSTREEVIEW tv; /*< The history treeview handle. */
bool open;
bool init;

View File

@ -23,8 +23,6 @@
#include <stdlib.h>
#include <time.h>
#include <windom.h>
#include "desktop/browser.h"
#include "content/content.h"
#include "content/hlcache.h"
@ -112,13 +110,15 @@ void hotlist_init(void)
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
short handle = -1;
GRECT desk;
OBJECT * tree = get_tree(TOOLBAR_HOTLIST);
assert( tree );
hl.open = false;
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);
wind_get_grect(0, WF_FULLXYWH, &desk);
handle = wind_create(flags, 0, 0, desk.g_w, desk.g_h);
hl.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
if( hl.window == NULL ) {
LOG(("Failed to allocate Hotlist"));
return;
@ -151,13 +151,19 @@ void hotlist_init(void)
void hotlist_open(void)
{
GRECT pos = {app.w - (app.w/3), app.y, app.w/3, app.h/2};
if( hl.init == false ) {
return;
}
if( hl.open == false ) {
GRECT pos;
wind_get_grect(0, WF_FULLXYWH, &pos);
pos.g_x = pos.g_w - pos.g_w / 4;
pos.g_y = pos.g_y;
pos.g_w = pos.g_w / 4;
pos.g_h = pos.g_h;
wind_open_grect(guiwin_get_handle(hl.window), &pos);
hl.open = true;
atari_treeview_open( hl.tv );

View File

@ -453,7 +453,7 @@ void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
}
//dbg_grect("atari_treeview_request_redraw", &tv->rdw_area);
dbg_grect("atari_treeview_request_redraw", &tv->rdw_area);
}
}