mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-17 06:54:42 +03:00
Treeview window event handling (currently just double-clicking hotlist items and
closing the window) svn path=/trunk/netsurf/; revision=5453
This commit is contained in:
parent
9c36d71ab8
commit
bc22f2e7d4
28
amiga/gui.c
28
amiga/gui.c
@ -404,6 +404,7 @@ void ami_handle_msg(void)
|
||||
struct nsObject *nnode;
|
||||
struct gui_window *gwin,*destroywin=NULL;
|
||||
struct MenuItem *item;
|
||||
struct InputEvent *ie;
|
||||
|
||||
node = (struct nsObject *)window_list->mlh_Head;
|
||||
|
||||
@ -411,6 +412,19 @@ void ami_handle_msg(void)
|
||||
{
|
||||
gwin = node->objstruct;
|
||||
|
||||
if(node->Type == AMINS_TVWINDOW)
|
||||
{
|
||||
if(ami_tree_event((struct treeviw_window *)gwin))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
node = nnode;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while((result = RA_HandleInput(gwin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
|
||||
{
|
||||
|
||||
@ -588,6 +602,8 @@ void ami_handle_msg(void)
|
||||
|
||||
case WMHI_RAWKEY:
|
||||
storage = result & WMHI_GADGETMASK;
|
||||
|
||||
GetAttr(WINDOW_InputEvent,gwin->objects[OID_MAIN],(ULONG *)&ie);
|
||||
switch(storage)
|
||||
{
|
||||
case RAWKEY_CRSRUP:
|
||||
@ -633,17 +649,7 @@ void ami_handle_msg(void)
|
||||
break;
|
||||
|
||||
case WMHI_CLOSEWINDOW:
|
||||
switch(node->Type)
|
||||
{
|
||||
case AMINS_TVWINDOW:
|
||||
ami_tree_close((struct treeview_window *)gwin);
|
||||
break;
|
||||
|
||||
default:
|
||||
browser_window_destroy(gwin->bw);
|
||||
break;
|
||||
}
|
||||
//destroywin=gwin;
|
||||
browser_window_destroy(gwin->bw);
|
||||
break;
|
||||
|
||||
case WMHI_INTUITICK:
|
||||
|
21
amiga/menu.c
21
amiga/menu.c
@ -31,6 +31,7 @@
|
||||
#include "desktop/save_text.h"
|
||||
#include "desktop/save_pdf/pdf_plotters.h"
|
||||
#include <string.h>
|
||||
#include "amiga/tree.h"
|
||||
|
||||
void ami_free_menulabs(void)
|
||||
{
|
||||
@ -61,9 +62,10 @@ void ami_init_menulabs(void)
|
||||
menulab[14] = ami_utf8_easy((char *)messages_get("Hotlist"));
|
||||
menulab[15] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
|
||||
menulab[16] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
|
||||
menulab[17] = ami_utf8_easy((char *)messages_get("Settings"));
|
||||
menulab[18] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
|
||||
menulab[19] = ami_utf8_easy((char *)messages_get("SettingsSave"));
|
||||
menulab[17] = ami_utf8_easy((char *)messages_get("Hotlist-browser"));
|
||||
menulab[18] = ami_utf8_easy((char *)messages_get("Settings"));
|
||||
menulab[19] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
|
||||
menulab[20] = ami_utf8_easy((char *)messages_get("SettingsSave"));
|
||||
}
|
||||
|
||||
struct NewMenu *ami_create_menu(ULONG type)
|
||||
@ -87,7 +89,8 @@ struct NewMenu *ami_create_menu(ULONG type)
|
||||
{ NM_ITEM,0,"Z",0,0,0,}, // clear selection
|
||||
{NM_TITLE,0,0,0,0,0,}, // hotlist
|
||||
{ NM_ITEM,0,0,0,0,0,}, // add to hotlist
|
||||
{ NM_ITEM,0,"H",0,0,0,}, // show hotlist
|
||||
{ NM_ITEM,0,"H",0,0,0,}, // show hotlist (treeview)
|
||||
{ NM_ITEM,0,0,0,0,0,}, // show hotlist (browser window)
|
||||
{NM_TITLE,0,0,0,0,0,}, // settings
|
||||
{ NM_ITEM,0,0,0,0,0,}, // snapshot window
|
||||
{ NM_ITEM,0,0,0,0,0,}, // save settings
|
||||
@ -208,6 +211,7 @@ void ami_menupick(ULONG code,struct gui_window *gwin)
|
||||
{
|
||||
case 0: // copy
|
||||
gui_copy_to_clipboard(gwin->bw->sel);
|
||||
browser_window_key_press(gwin->bw, 26);
|
||||
break;
|
||||
|
||||
case 1: // paste
|
||||
@ -232,10 +236,15 @@ void ami_menupick(ULONG code,struct gui_window *gwin)
|
||||
options_save_tree(hotlist,"Resources/Hotlist","NetSurf hotlist");
|
||||
break;
|
||||
|
||||
case 1: // show
|
||||
/* this along with save_tree above is very temporary! */
|
||||
case 2: // show
|
||||
/* this along with save_tree above is very temporary!
|
||||
config option for this? */
|
||||
browser_window_go(gwin->bw,"file:///netsurf/resources/hotlist",NULL,true);
|
||||
break;
|
||||
|
||||
case 1: // show
|
||||
ami_open_tree(hotlist);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define AMIGA_MENU_H
|
||||
#include <exec/types.h>
|
||||
|
||||
#define AMI_MENU_MAX 19
|
||||
#define AMI_MENU_MAX 20
|
||||
char *menulab[AMI_MENU_MAX+1];
|
||||
|
||||
struct NewMenu *ami_create_menu(ULONG type);
|
||||
|
137
amiga/tree.c
137
amiga/tree.c
@ -31,17 +31,9 @@
|
||||
#include <proto/intuition.h>
|
||||
#include "amiga/tree.h"
|
||||
|
||||
struct treeview_window {
|
||||
struct Window *win;
|
||||
Object *objects[OID_LAST];
|
||||
struct Gadget *gadgets[GID_LAST];
|
||||
struct nsObject *node;
|
||||
ULONG pad[5];
|
||||
struct tree *tree;
|
||||
struct List *listbrowser_list;
|
||||
};
|
||||
|
||||
void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen);
|
||||
bool ami_tree_launch_node(struct tree *tree, struct node *node);
|
||||
void free_browserlist(struct List *list);
|
||||
|
||||
void tree_initialise_redraw(struct tree *tree)
|
||||
{
|
||||
@ -184,7 +176,14 @@ void ami_open_tree(struct tree *tree)
|
||||
struct treeview_window *twin;
|
||||
BOOL msel = TRUE;
|
||||
static WORD gen=0;
|
||||
/* open window with listbrowser gadget added */
|
||||
|
||||
if(tree->handle)
|
||||
{
|
||||
twin = tree->handle;
|
||||
WindowToFront(twin->win);
|
||||
ActivateWindow(twin->win);
|
||||
return;
|
||||
}
|
||||
|
||||
twin = AllocVec(sizeof(struct treeview_window),MEMF_CLEAR);
|
||||
twin->listbrowser_list = AllocVec(sizeof(struct List),MEMF_CLEAR);
|
||||
@ -214,7 +213,8 @@ void ami_open_tree(struct tree *tree)
|
||||
WA_CloseGadget, TRUE,
|
||||
WA_SizeGadget, TRUE,
|
||||
WA_CustomScreen,scrn,
|
||||
WINDOW_SharedPort,sport,
|
||||
WINDOW_SharedPort,sport,
|
||||
WINDOW_UserData,twin,
|
||||
WINDOW_IconifyGadget, TRUE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WINDOW_ParentGroup, twin->gadgets[GID_MAIN] = VGroupObject,
|
||||
@ -225,11 +225,13 @@ void ami_open_tree(struct tree *tree)
|
||||
LISTBROWSER_ColumnInfo, &columninfo,
|
||||
LISTBROWSER_ColumnTitles, TRUE,
|
||||
LISTBROWSER_Hierarchical,TRUE,
|
||||
LISTBROWSER_Editable,TRUE,
|
||||
// LISTBROWSER_TitleClickable,TRUE,
|
||||
LISTBROWSER_AutoFit, TRUE,
|
||||
LISTBROWSER_HorizontalProp, TRUE,
|
||||
LISTBROWSER_Labels, twin->listbrowser_list,
|
||||
LISTBROWSER_MultiSelect,msel,
|
||||
LISTBROWSER_ShowSelected,TRUE,
|
||||
ListBrowserEnd,
|
||||
CHILD_NominalSize,TRUE,
|
||||
EndGroup,
|
||||
@ -272,15 +274,14 @@ bool ami_tree_launch_node(struct tree *tree, struct node *node)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ami_tree_close(struct tree *tree)
|
||||
void ami_tree_close(struct treeview_window *twin)
|
||||
{
|
||||
struct treeview_window *twin = tree->handle;
|
||||
|
||||
twin->tree->handle = NULL;
|
||||
DisposeObject(twin->objects[OID_MAIN]);
|
||||
FreeListBrowserList(twin->listbrowser_list);
|
||||
FreeVec(twin->listbrowser_list);
|
||||
//free_browserlist(twin->listbrowser_list);
|
||||
DelObject(twin->node);
|
||||
win_destroyed = true;
|
||||
}
|
||||
|
||||
void free_browserlist(struct List *list)
|
||||
@ -307,33 +308,55 @@ void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen)
|
||||
BOOL edit = FALSE;
|
||||
struct node_element *element=NULL,*element2=NULL,*element3=NULL;
|
||||
struct node *node;
|
||||
ULONG flags = 0;
|
||||
STRPTR text1 = "",text2 = "",text3 = "";
|
||||
|
||||
*gen = *gen + 1;
|
||||
for (node = root; node; node = node->next)
|
||||
{
|
||||
element = tree_find_element(node, TREE_ELEMENT_NAME);
|
||||
if(!element) element = tree_find_element(node, TREE_ELEMENT_TITLE);
|
||||
if(element && element->text)
|
||||
{
|
||||
text1 = element->text;
|
||||
}
|
||||
|
||||
// printf("node %lx url %s gen %ld\n",node,element->text,*gen);
|
||||
element2 = tree_find_element(node, TREE_ELEMENT_URL);
|
||||
element3 = tree_find_element(node, TREE_ELEMENT_VISITS);
|
||||
|
||||
if(element2 && element2->text)
|
||||
{
|
||||
text2 = element2->text;
|
||||
}
|
||||
|
||||
// element = tree_find_element(node, TREE_ELEMENT_VISITS);
|
||||
|
||||
if(node->expanded) flags = LBFLG_SHOWCHILDREN;
|
||||
|
||||
switch (element->type) {
|
||||
case NODE_ELEMENT_TEXT_PLUS_SPRITE:
|
||||
case NODE_ELEMENT_TEXT:
|
||||
if (lbnode = AllocListBrowserNode(3,
|
||||
// LBNA_UserData,nodetime,
|
||||
LBNA_Generation,*gen,
|
||||
LBNA_UserData,node,
|
||||
LBNA_Generation,*gen,
|
||||
LBNA_Selected,node->selected,
|
||||
LBNA_Flags,flags,
|
||||
LBNA_Column, 0,
|
||||
LBNCA_CopyText,TRUE,
|
||||
LBNCA_Text, element->text,
|
||||
LBNCA_Editable,edit,
|
||||
LBNA_Column, 1,
|
||||
LBNCA_CopyText,TRUE,
|
||||
LBNCA_Text, element2->text,
|
||||
LBNA_Column, 2,
|
||||
LBNCA_CopyText,TRUE,
|
||||
LBNCA_Text, "",
|
||||
TAG_DONE))
|
||||
LBNCA_CopyText,TRUE,
|
||||
LBNCA_MaxChars,256,
|
||||
LBNCA_Text, text1,
|
||||
LBNCA_Editable,node->editable,
|
||||
LBNA_Column, 1,
|
||||
LBNCA_CopyText,TRUE,
|
||||
LBNCA_MaxChars,256,
|
||||
LBNCA_Text, text2,
|
||||
LBNCA_Editable,node->editable,
|
||||
LBNA_Column, 2,
|
||||
LBNCA_CopyText,TRUE,
|
||||
LBNCA_MaxChars,256,
|
||||
LBNCA_Text,"",
|
||||
LBNCA_Editable,node->editable,
|
||||
TAG_DONE))
|
||||
{
|
||||
AddTail(twin->listbrowser_list, lbnode);
|
||||
}
|
||||
@ -347,3 +370,59 @@ void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen)
|
||||
}
|
||||
*gen = *gen - 1;
|
||||
}
|
||||
|
||||
BOOL ami_tree_event(struct treeview_window *twin)
|
||||
{
|
||||
/* return TRUE if window destroyed */
|
||||
ULONG class,result,relevent = 0;
|
||||
uint16 code;
|
||||
struct MenuItem *item;
|
||||
struct node *treenode;
|
||||
struct Node *lbnode;
|
||||
|
||||
while((result = RA_HandleInput(twin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
|
||||
{
|
||||
switch(result & WMHI_CLASSMASK) // class
|
||||
{
|
||||
case WMHI_GADGETUP:
|
||||
switch(result & WMHI_GADGETMASK)
|
||||
{
|
||||
case GID_TREEBROWSER:
|
||||
GetAttrs(twin->gadgets[GID_TREEBROWSER],
|
||||
LISTBROWSER_RelEvent,&relevent,
|
||||
TAG_DONE);
|
||||
|
||||
switch(relevent)
|
||||
{
|
||||
case LBRE_DOUBLECLICK:
|
||||
GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
|
||||
GetListBrowserNodeAttrs(lbnode,
|
||||
LBNA_UserData,(ULONG *)&treenode,
|
||||
TAG_DONE);
|
||||
ami_tree_launch_node(twin->tree,treenode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
/* no menus yet, copied in as will probably need it later
|
||||
case WMHI_MENUPICK:
|
||||
item = ItemAddress(gwin->win->MenuStrip,code);
|
||||
while (code != MENUNULL)
|
||||
{
|
||||
ami_menupick(code,gwin);
|
||||
if(win_destroyed) break;
|
||||
code = item->NextSelect;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
|
||||
case WMHI_CLOSEWINDOW:
|
||||
ami_tree_close(twin);
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
15
amiga/tree.h
15
amiga/tree.h
@ -19,8 +19,17 @@
|
||||
#ifndef AMIGA_TREE_H
|
||||
#define AMIGA_TREE_H
|
||||
|
||||
struct treeview_window {
|
||||
struct Window *win;
|
||||
Object *objects[OID_LAST];
|
||||
struct Gadget *gadgets[GID_LAST];
|
||||
struct nsObject *node;
|
||||
ULONG pad[5];
|
||||
struct tree *tree;
|
||||
struct List *listbrowser_list;
|
||||
};
|
||||
|
||||
void ami_open_tree(struct tree *tree);
|
||||
bool ami_tree_launch_node(struct tree *tree, struct node *node);
|
||||
void ami_tree_close(struct tree *tree);
|
||||
void free_browserlist(struct List *list);
|
||||
void ami_tree_close(struct treeview_window *twin);
|
||||
BOOL ami_tree_event(struct treeview_window *twin);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user