Commit 1c84dd99 authored by David Brown's avatar David Brown
Browse files

Extended API and fixed window opening bug

parent 5d3733cf
......@@ -3296,6 +3296,15 @@ _kernel_oserror * hotlist_open(int show_type, void * type, int show_urls)
/* Show the hotlist */
/* Open window once to let the wimp/toolbox see what shape it really is */
e = toolbox_show_object(0,
hotlist_windowid,
Toolbox_ShowObject_Default,
0,
0,
0);
/* Open it once again in the place the window is really wanted */
e = toolbox_show_object(0,
hotlist_windowid,
show_type,
......@@ -4051,7 +4060,7 @@ static int hotlist_drag_completed_handler(int event_code, WimpPollBlock *event,
if (!hotlist_dragging) return 0;
show_error_ret(hotlist_autoscroll(0)); /* Reset autoscrolling (To remove pointer if necessary) */
show_error_ret(hotlist_autoscroll(0)); /* Reset autoscrolling (To restore pointer if necessary) */
switch(hotlist_dragging)
{
......@@ -4511,7 +4520,10 @@ static int hotlist_null_handler(int event_code, WimpPollBlock *event, IdBlock *i
/* Simple non-scrolling selection box, to be improved later */
/* Workarea relative corner of selection box may not be needed later */
static int selection_x, selection_y; ////////////
///////////////////////////////////////////////////////////////////////
static int selection_x, selection_y;
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
/*************************************************/
/* hotlist_start_drag() */
......@@ -5058,3 +5070,124 @@ static int hotlist_ram_fetch_handler(WimpMessage *message, void *handle)
}
return 0;
}
/*************************************************/
/* hotlist_read_toolbox_id() */
/* */
/* Returns: the hotlist window toolbox id */
/*************************************************/
ObjectId hotlist_read_toolbox_id(void)
{
return hotlist_windowid;
}
/*************************************************/
/* hotlist_add_position() */
/* */
/* Add a new URL to the hotlist at a specified */
/* position.  */
/* */
/* Parameters: screen relative x position */
/* */
/* screen relative y position */
/* */
/* Description of the URL (e.g. from */
/* the page title); */
/* */
/* Pointer to the URL itself; */
/*************************************************/
_kernel_oserror * hotlist_add_position(int x, int y, char *description, char *url)
{
_kernel_oserror *e;
WimpGetWindowStateBlock state;
int winx, winy, top, position;
hotlist_item * targetitem;
unsigned int item_height, item_dir_width, item_url_width, xmin, xmax;
/* Calculate window relative coordinates */
RetError(window_wimp_to_toolbox(0,
hotlist_windowid,
0,
&state.window_handle,
NULL));
RetError(wimp_get_window_state(&state));
winx = x + (state.xscroll - state.visible_area.xmin);
winy = y + (state.yscroll - state.visible_area.ymax);
/* Calculate which item add is over */
hotlist_get_entry_sizes(&item_height, &item_dir_width, &item_url_width);
targetitem = hotlist_find_item(hotlist_root->data.directory_content, -winy/item_height);
top = -winy/item_height;
/* Decide where to put the new item */
if (targetitem)
{
hotlist_get_shape(&xmin, &xmax, targetitem);
if (targetitem->type == hl_directory && winx >= xmin && winx <= xmin+item_dir_width)
{
/* Put item in directory */
position = HOTLIST_POSITION_BEGINNING;
}
else
{
if ((-winy % item_height) > item_height / 2)
{
/* Put item after target item */
position = HOTLIST_POSITION_AFTER;
}
else
{
/* Put item before target item */
position = HOTLIST_POSITION_BEFORE;
}
}
}
else
{
/* Put item at end of root directory */
position = HOTLIST_POSITION_END;
targetitem = hotlist_root;
}
/* Create new item in appropriate place */
e = hotlist_new_url(targetitem,
position,
description,
url);
if (!e) hotlist_window_preopen(already_open);
/* Optimise the redraw to do as little as possible depending */
/* upon where in the list the item was added. */
switch (position)
{
case HOTLIST_POSITION_END:
{
hotlist_redraw_now();
}
break;
case HOTLIST_POSITION_BEGINNING:
{
hotlist_clear_flags(hotlist_root, hl_ALL, HOTLIST_G_REDRAW_NOW);
hotlist_redraw_items(0,
hotlist_count_displayed_items(hotlist_root->data.directory_content));
}
break;
default:
{
hotlist_clear_flags(hotlist_root, hl_ALL, HOTLIST_G_REDRAW_NOW);
hotlist_redraw_items(-winy/item_height - 1,
hotlist_count_displayed_items(hotlist_root->data.directory_content));
}
break;
}
if (!e) return hotlist_modified(HL_MODIFIED_ADD);
return e;
}
......@@ -205,14 +205,17 @@
/* Function prototypes */
_kernel_oserror * hotlist_initialise (void);
_kernel_oserror * hotlist_initialise (void);
_kernel_oserror * hotlist_open (int show_type, void * type, int show_urls);
_kernel_oserror * hotlist_close (void);
_kernel_oserror * hotlist_open (int show_type, void * type, int show_urls);
_kernel_oserror * hotlist_close (void);
ObjectId hotlist_read_toolbox_id (void);
_kernel_oserror * hotlist_load (char * filename);
_kernel_oserror * hotlist_save (char * filename);
_kernel_oserror * hotlist_load (char * filename);
_kernel_oserror * hotlist_save (char * filename);
_kernel_oserror * hotlist_add (char * description, char * url, int at_bottom);
_kernel_oserror * hotlist_add_position (int x, int y, char * description, char * url);
_kernel_oserror * hotlist_add (char * description, char * url, int at_bottom);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment