24#include <proto/exec.h>
25#include <proto/intuition.h>
26#include <proto/layout.h>
27#include <proto/listbrowser.h>
28#include <proto/utility.h>
29#include <proto/string.h>
30#include <proto/window.h>
32#include <classes/window.h>
33#include <gadgets/layout.h>
34#include <gadgets/listbrowser.h>
50static void myStringOpenListview( Class *cl, Object *obj,
struct gpInput *msg );
51static void myStringCloseListview( Class *cl, Object *obj );
52static uint32 myStringSearch( Class *cl, Object *obj );
53static void myStringArrowUp( Class *cl, Object *obj );
54static void myStringArrowDown( Class *cl, Object *obj );
55static void myStringHandleListview( Class *cl, Object *obj );
63static void myStringOpenListview( Class *cl, Object *obj,
struct gpInput *msg )
68 data = INST_DATA( cl, obj );
70 gad = (
struct Gadget *)obj;
73 WA_CustomScreen, msg->gpi_GInfo->gi_Window->WScreen,
85 if ( data->
Window == NULL )
100static void myStringCloseListview( Class *cl, Object *obj )
105 data = INST_DATA( cl, obj );
115 FreeListBrowserNode( node );
122static uint32 myStringSearch( Class *cl, Object *obj )
135 data = INST_DATA( cl, obj );
142 LISTBROWSER_Labels, ~0,
148 FreeListBrowserNode( node );
151 GetAttr( STRINGA_BufferPos, obj, &bufpos );
180 compString = strstr(node->ln_Name,
"://");
184 compString = node->ln_Name;
186 if( 0 == strncasecmp( compString, searchString, bufpos ) )
194 if( 0 == strncasecmp( compString,
"www.", 4) ) {
196 if( 0 == strncasecmp( &compString[4], searchString, bufpos ) )
201 if ( possible == TRUE )
203 n = AllocListBrowserNode( 1,
205 LBNCA_CopyText, TRUE,
206 LBNCA_Text, node->ln_Name,
232 LISTBROWSER_MakeVisible, 0,
242static void myStringArrowUp( Class *cl, Object *obj )
249 data = INST_DATA( cl, obj );
293static void myStringArrowDown( Class *cl, Object *obj )
298 data = INST_DATA( cl, obj );
325static void myStringHandleListview( Class *cl, Object *obj )
331 data = INST_DATA( cl, obj );
357static uint32 myStringClass_OM_New( Class *cl, Object *obj,
struct opSet *msg )
361 struct TagItem *tag, *tags;
367 tags = msg->ops_AttrList;
369 while(( tag = NextTagItem( &tags )))
371 switch ( tag->ti_Tag )
375 header = (
struct List *)tag->ti_Data;
381 buffer = (STRPTR)tag->ti_Data;
392 if (( header == NULL ) || (
buffer == NULL ))
406 data = INST_DATA( cl, obj );
419 LAYOUT_SpaceInner, FALSE,
420 LAYOUT_SpaceOuter, FALSE,
423 LISTBROWSER_MakeVisible, TRUE,
424 LISTBROWSER_ShowSelected, TRUE,
450static uint32 myStringClass_OM_Dispose( Class *cl, Object *obj,
struct opSet *msg )
454 data = INST_DATA( cl, obj );
566static uint32 myStringClass_GM_HandleInput( Class *cl, Object *obj,
struct gpInput *msg )
572 data = INST_DATA( cl, obj );
574 gad = (
struct Gadget *)obj;
578 if (( gad->Flags & GFLG_SELECTED ) == 0 )
580 return( GMR_NOREUSE );
583 switch( msg->gpi_IEvent->ie_Class )
587 switch( msg->gpi_IEvent->ie_Code )
592 myStringArrowUp( cl, obj );
594 retval = GMR_MEACTIVE;
602 myStringArrowDown( cl, obj );
604 retval = GMR_MEACTIVE;
623 struct Node *selected = NULL;
626 if( selected != NULL )
628 GetListBrowserNodeAttrs( selected, LBNA_Column, 0, LBNCA_Text, &pText, TAG_END );
629 SetGadgetAttrs( (
struct Gadget *)obj, data->
Window, NULL, STRINGA_TextVal, pText, TAG_DONE );
642 GetAttr( STRINGA_BufferPos, obj, &oldpos );
646 GetAttr( STRINGA_BufferPos, obj, &newpos );
648 if ( oldpos != newpos )
650 if ( myStringSearch( cl, obj ))
653 if ( data->
Window == NULL )
655 myStringOpenListview( cl, obj, msg );
661 myStringCloseListview( cl, obj );
668 myStringHandleListview( cl, obj );
672 case IECLASS_MOUSEWHEEL:
674 struct InputEvent *ie = msg->gpi_IEvent;
678 myStringArrowUp( cl, obj );
680 else if ( ie->ie_Y > 0 )
682 myStringArrowDown( cl, obj );
685 myStringHandleListview( cl, obj );
687 retval = GMR_MEACTIVE;
704static uint32 myStringClass_GM_GoActive( Class *cl, Object *obj,
struct gpInput *msg )
711 data = INST_DATA( cl, obj );
713 gad = (
struct Gadget *)obj;
715 if ( gad->Flags & GFLG_DISABLED )
717 myStringCloseListview( cl, obj );
719 retval = GMR_NOREUSE;
724 gad->Flags |= GFLG_SELECTED;
726 win = msg->gpi_GInfo->gi_Window;
730 data->
WinXPos = win->LeftEdge + gad->LeftEdge;
731 data->
WinYPos = win->TopEdge + gad->TopEdge + gad->Height - 1;
736 if ( myStringSearch( cl, obj ))
739 if ( data->
Window == NULL )
741 myStringOpenListview( cl, obj, msg );
747 myStringCloseListview( cl, obj );
759static uint32 myStringClass_GM_GoInactive( Class *cl, Object *obj,
struct gpGoInactive *msg )
763 data = INST_DATA( cl, obj );
765 myStringCloseListview( cl, obj );
776static uint32 myStringClassDispatcher( Class *cl, Object *obj, Msg msg )
781 if ( msg->MethodID == OM_NEW )
783 return( myStringClass_OM_New( cl, obj, (APTR)msg ));
785 else if ( msg->MethodID == OM_DISPOSE )
787 return( myStringClass_OM_Dispose( cl, obj, (APTR)msg ));
791 data = INST_DATA( cl, obj );
795 switch( msg->MethodID )
800 struct TagItem *tag, *tags;
801 struct opSet *opSet = (
struct opSet *)msg;
802 tags = opSet->ops_AttrList;
803 while ((tag = NextTagItem(&tags)))
805 if (STRINGA_TextVal == tag->ti_Tag)
824 case GM_HANDLEINPUT: ret = myStringClass_GM_HandleInput( cl, obj, (APTR)msg );
break;
825 case GM_GOACTIVE: ret = myStringClass_GM_GoActive( cl, obj, (APTR)msg );
break;
826 case GM_GOINACTIVE: ret = myStringClass_GM_GoInactive( cl, obj, (APTR)msg );
break;
851 cl->cl_Dispatcher.h_Entry = (
uint32(*)(void))myStringClassDispatcher;
static osspriteop_area * buffer
The buffer characteristics.
APTR NewObject(struct IClass *classPtr, CONST_STRPTR classID, ULONG tagList,...)
struct Node * GetHead(struct List *list)
ULONG RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1,...)
struct Node * GetSucc(struct Node *node)
Interface to utility string handling.
Class * MakeStringClass(void)
#define STRINGVIEW_Header
void FreeStringClass(Class *)
struct List ListviewHeader
struct List * SearchHeader
struct SignalSemaphore Semaphore
void URLHistory_Free(void)
void URLHistory_Init(void)
void URLHistory_AddPage(const char *urlString)