1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
19 ***************************************************************************/
23 #define CATCOMP_NUMBERS
27 #include <libraries/openurl.h>
34 /**************************************************************************/
36 ** Little lamp class for enabled/disabled
39 static struct MUI_CustomClass
*lampClass
= NULL
;
40 #define lampObject NewObject(lampClass->mcc_Class,NULL
55 FLG_LampDisabled
= 1<<1,
58 /***********************************************************************/
60 static IPTR
mLampNew(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
62 return (IPTR
)DoSuperNew(cl
,obj
,
63 MUIA_Font
, MUIV_Font_List
,
64 TAG_MORE
, msg
->ops_AttrList
);
67 /**************************************************************************/
69 static IPTR
mLampSets(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
71 struct lampData
*data
= INST_DATA(cl
,obj
);
74 if((tag
= FindTagItem(MUIA_Lamp_Disabled
,msg
->ops_AttrList
)))
77 SET_FLAG(data
->flags
, FLG_LampDisabled
);
79 CLEAR_FLAG(data
->flags
, FLG_LampDisabled
);
81 /* Of course, we don't redraw here */
84 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
87 /***********************************************************************/
89 static IPTR
mLampSetup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
91 struct lampData
*data
= INST_DATA(cl
,obj
);
92 if (!DoSuperMethodA(cl
,obj
,(APTR
)msg
)) return FALSE
;
94 if (MUIMasterBase
->lib_Version
<20)
96 data
->enabled
= MUI_ObtainPen(muiRenderInfo(obj
),(APTR
)"r00000000,ffffffff,00000000",0);
97 data
->disabled
= MUI_ObtainPen(muiRenderInfo(obj
),(APTR
)"rffffffff,00000000,00000000",0);
98 data
->detail
= MUI_ObtainPen(muiRenderInfo(obj
),(APTR
)"r00000000,00000000,00000000",0);
102 data
->enabled
= MUI_ObtainPen(muiRenderInfo(obj
),(APTR
)"r02ff00",0);
103 data
->disabled
= MUI_ObtainPen(muiRenderInfo(obj
),(APTR
)"rff0000",0);
104 data
->detail
= MUI_ObtainPen(muiRenderInfo(obj
),(APTR
)"r000000",0);
107 SET_FLAG(data
->flags
, FLG_LampSetup
);
112 /***********************************************************************/
114 static IPTR
mLampCleanup(struct IClass
*cl
,Object
*obj
,struct MUIP_Setup
*msg
)
116 struct lampData
*data
= INST_DATA(cl
,obj
);
118 if(isFlagSet(data
->flags
, FLG_LampSetup
))
120 MUI_ReleasePen(muiRenderInfo(obj
),data
->enabled
);
121 MUI_ReleasePen(muiRenderInfo(obj
),data
->disabled
);
122 MUI_ReleasePen(muiRenderInfo(obj
),data
->detail
);
124 CLEAR_FLAG(data
->flags
, FLG_LampSetup
);
127 return DoSuperMethodA(cl
,obj
,(APTR
)msg
);
130 /***********************************************************************/
132 static IPTR
mLampAskMinMax(struct IClass
*cl
, Object
*obj
, struct MUIP_AskMinMax
*msg
)
134 struct lampData
*data
= INST_DATA(cl
,obj
);
136 struct TextExtent te
;
139 DoSuperMethodA(cl
,obj
,(APTR
)msg
);
141 CopyMem(&_screen(obj
)->RastPort
,&rp
,sizeof(rp
));
143 /* Don't ask or modify ! */
145 SetFont(&rp
,_font(obj
));
146 TextExtent(&rp
," ",2,&te
);
154 data
->delta
= te
.te_Extent
.MinY
;
156 msg
->MinMaxInfo
->MinWidth
+= d
;
157 msg
->MinMaxInfo
->MinHeight
+= h
;
158 msg
->MinMaxInfo
->DefWidth
+= d
;
159 msg
->MinMaxInfo
->DefHeight
+= h
;
160 msg
->MinMaxInfo
->MaxWidth
+= d
;
161 msg
->MinMaxInfo
->MaxHeight
+= h
;
166 /***********************************************************************/
168 static IPTR
mLampDraw(struct IClass
*cl
, Object
*obj
, struct MUIP_Draw
*msg
)
170 struct lampData
*data
= INST_DATA(cl
,obj
);
173 res
= DoSuperMethodA(cl
,obj
,(APTR
)msg
);
175 if(hasFlag(msg
->flags
, (MADF_DRAWOBJECT
|MADF_DRAWUPDATE
)))
179 /* Don't ask or modify ! */
183 t
= _mtop(obj
)+(_mheight(obj
)+data
->delta
)/2-1;
198 SetAPen(_rp(obj
), MUIPEN(isFlagSet(data
->flags
, FLG_LampDisabled
) ? data
->disabled
: data
->enabled
));
199 RectFill(_rp(obj
),l
,t
,r
,b
);
201 SetAPen(_rp(obj
),MUIPEN(data
->detail
));
212 /***********************************************************************/
214 SDISPATCHER(lampDispatcher
)
216 switch(msg
->MethodID
)
218 case OM_NEW
: return mLampNew(cl
,obj
,(APTR
)msg
);
219 case OM_SET
: return mLampSets(cl
,obj
,(APTR
)msg
);
221 case MUIM_Setup
: return mLampSetup(cl
,obj
,(APTR
)msg
);
222 case MUIM_Cleanup
: return mLampCleanup(cl
,obj
,(APTR
)msg
);
223 case MUIM_AskMinMax
: return mLampAskMinMax(cl
,obj
,(APTR
)msg
);
224 case MUIM_Draw
: return mLampDraw(cl
,obj
,(APTR
)msg
);
226 default: return DoSuperMethodA(cl
,obj
,msg
);
230 /***********************************************************************/
232 static BOOL
initLampClass(void)
234 BOOL success
= FALSE
;
238 if((lampClass
= MUI_CreateCustomClass(NULL
, MUIC_Rectangle
, NULL
, sizeof(struct lampData
), ENTRY(lampDispatcher
))) != NULL
)
245 /**************************************************************************/
247 static void disposeLampClass(void)
249 if(lampClass
!= NULL
)
250 MUI_DeleteCustomClass(lampClass
);
253 /**************************************************************************/
255 ** List of clients with lamps
258 static struct MUI_CustomClass
*listClass
= NULL
;
259 #define listObject NewObject(listClass->mcc_Class,NULL
265 TEXT col0buf
[NAME_LEN
+16];
277 struct Hook dispHook
;
282 FLG_ListSetup
= 1<<0,
285 /* Used for Import/Export */
292 /**************************************************************************/
294 HOOKPROTO(conFunc
, struct URL_Node
*, APTR pool
, struct URL_Node
*node
)
296 struct listData
*data
= hook
->h_Data
;
297 struct URL_Node
*new;
299 if(isFlagSet(node
->Flags
, UNF_NTALLOC
))
302 CLEAR_FLAG(node
->Flags
, UNF_NTALLOC
);
304 else if((new = AllocPooled(pool
,data
->nodeSize
)) != NULL
)
305 CopyMem(node
, new, data
->nodeSize
);
309 MakeStaticHook(conHook
, conFunc
);
311 /**************************************************************************/
313 HOOKPROTO(desFunc
, void, APTR pool
, struct URL_Node
*node
)
315 struct listData
*data
= hook
->h_Data
;
317 FreePooled(pool
,node
,data
->nodeSize
);
319 MakeStaticHook(desHook
, desFunc
);
321 /**************************************************************************/
323 HOOKPROTO(dispFunc
, void, STRPTR
*array
, struct URL_Node
*node
)
325 struct listData
*data
= hook
->h_Data
;
331 set(data
->olamp
, MUIA_Lamp_Disabled
, isFlagSet(node
->Flags
, UNF_DISABLED
));
332 #if defined(__LP64__)
333 sprintf(data
->col0buf
,"\33O[%016lx]", (IPTR
)data
->lamp
);
335 sprintf(data
->col0buf
,"\33O[%08lx]", (IPTR
)data
->lamp
);
337 *array
++ = data
->col0buf
;
340 *array
++ = (STRPTR
)(isFlagSet(node
->Flags
, UNF_DISABLED
) ? " " : ">");
342 *array
++ = (STRPTR
)node
+data
->nameOfs
;
343 *array
= (STRPTR
)node
+data
->pathOfs
;
347 *array
++ = (STRPTR
)" ";
348 *array
++ = getString(MSG_Edit_ListName
);
349 *array
= getString(MSG_Edit_ListPath
);
352 MakeStaticHook(dispHook
, dispFunc
);
354 /**************************************************************************/
356 static IPTR
mListNew(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
358 if((obj
= (Object
*)DoSuperNew(cl
,obj
,
360 MUIA_List_Title
, TRUE
,
361 MUIA_List_Format
, "C=0,C=1,C=2",
362 MUIA_List_DragSortable
, TRUE
,
363 MUIA_List_Pool
, g_pool
,
364 MUIA_List_DragSortable
, TRUE
,
365 MUIA_List_ShowDropMarks
, TRUE
,
366 TAG_MORE
, msg
->ops_AttrList
)) != NULL
)
368 struct listData
*data
= INST_DATA(cl
,obj
);
370 // the hooks make use of the instance data and hence must not
371 // put the data pointer into the global hook definitions
372 InitHook(&data
->conHook
, conHook
, data
);
373 InitHook(&data
->desHook
, desHook
, data
);
374 InitHook(&data
->dispHook
, dispHook
, data
);
376 // now tell the list object to use the local hooks
377 set(obj
, MUIA_List_ConstructHook
, &data
->conHook
);
378 set(obj
, MUIA_List_DestructHook
, &data
->desHook
);
379 set(obj
, MUIA_List_DisplayHook
, &data
->dispHook
);
381 data
->nameOfs
= GetTagData(MUIA_AppList_NodeNameOffset
,0,msg
->ops_AttrList
);
382 data
->pathOfs
= GetTagData(MUIA_AppList_NodePathOffset
,0,msg
->ops_AttrList
);
383 data
->nodeSize
= GetTagData(MUIA_AppList_NodeSize
,0,msg
->ops_AttrList
);
385 strlcpy(data
->format
,"C=0,C=1,C=2", sizeof(data
->format
));
387 if (lampClass
) data
->olamp
= lampObject
, End
;
394 /**************************************************************************/
396 static IPTR
mListDispose(struct IClass
*cl
, Object
*obj
, Msg msg
)
398 struct listData
*data
= INST_DATA(cl
,obj
);
400 if (data
->olamp
) MUI_DisposeObject(data
->olamp
);
402 return DoSuperMethodA(cl
,obj
,msg
);
405 /**************************************************************************/
407 static IPTR
mListSetup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
413 if(DoSuperMethodA(cl
, obj
, (APTR
)msg
))
415 struct listData
*data
= INST_DATA(cl
, obj
);
417 if(isFlagClear(data
->flags
, FLG_ListSetup
))
419 /* After thinking about that hard, I decided to use the lamp in >=8 color screen */
420 if(data
->olamp
!= NULL
&& GetBitMapAttr(_screen(obj
)->RastPort
.BitMap
, BMA_DEPTH
) > 3)
421 data
->lamp
= (APTR
)DoSuperMethod(cl
, obj
, MUIM_List_CreateImage
, (IPTR
)data
->olamp
, 0);
423 SET_FLAG(data
->flags
, FLG_ListSetup
);
433 /***********************************************************************/
435 static IPTR
mListCleanup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
438 struct listData
*data
= INST_DATA(cl
, obj
);
442 if(isFlagSet(data
->flags
, FLG_ListSetup
))
444 if(data
->lamp
!= NULL
)
446 DoSuperMethod(cl
, obj
, MUIM_List_DeleteImage
, (IPTR
)data
->lamp
);
450 CLEAR_FLAG(data
->flags
, FLG_ListSetup
);
453 result
= DoSuperMethodA(cl
, obj
, (APTR
)msg
);
459 /***********************************************************************/
464 static IPTR
mListImport(struct IClass
*cl
, Object
*obj
, struct MUIP_Import
*msg
)
468 if(MUIMasterBase
->lib_Version
< 20)
471 if((id
= (muiNotifyData(obj
)->mnd_ObjectID
)) != 0)
475 if((io
= (struct listIO
*)DoMethod(msg
->dataspace
,MUIM_Dataspace_Find
, id
)) != NULL
)
477 struct listData
*data
= INST_DATA(cl
,obj
);
479 strlcpy(data
->format
, io
->format
, sizeof(data
->format
));
480 set(obj
,MUIA_List_Format
,data
->format
);
487 /***********************************************************************/
492 static IPTR
mListExport(UNUSED
struct IClass
*cl
, Object
*obj
, struct MUIP_Import
*msg
)
496 if(MUIMasterBase
->lib_Version
< 20)
499 if((id
= (muiNotifyData(obj
)->mnd_ObjectID
)) != 0)
504 if((f
= (STRPTR
)xget(obj
, MUIA_List_Format
)) != NULL
)
506 io
.len
= strlen(f
)+1;
507 strlcpy(io
.format
, f
, sizeof(io
.format
));
509 DoMethod(msg
->dataspace
,MUIM_Dataspace_Add
,(IPTR
)&io
,sizeof(ULONG
)+io
.len
,id
);
516 /**************************************************************************/
518 ** Check if format changed
521 static IPTR
mListCheckSave(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
523 struct listData
*data
= INST_DATA(cl
,obj
);
526 if((f
= (STRPTR
)xget(obj
, MUIA_List_Format
)) != NULL
)
527 return (IPTR
)strcmp(f
,(STRPTR
)&data
->format
);
532 /**************************************************************************/
534 SDISPATCHER(listDispatcher
)
536 switch (msg
->MethodID
)
538 case OM_NEW
: return mListNew(cl
,obj
,(APTR
)msg
);
539 case OM_DISPOSE
: return mListDispose(cl
,obj
,(APTR
)msg
);
541 case MUIM_Setup
: return mListSetup(cl
,obj
,(APTR
)msg
);
542 case MUIM_Cleanup
: return mListCleanup(cl
,obj
,(APTR
)msg
);
543 case MUIM_Import
: return mListImport(cl
,obj
,(APTR
)msg
);
544 case MUIM_Export
: return mListExport(cl
,obj
,(APTR
)msg
);
546 case MUIM_App_CheckSave
: return mListCheckSave(cl
,obj
,(APTR
)msg
);
548 default: return DoSuperMethodA(cl
,obj
,msg
);
552 /**************************************************************************/
554 static BOOL
initListClass(void)
556 BOOL success
= FALSE
;
560 if((listClass
= MUI_CreateCustomClass(NULL
, MUIC_List
, NULL
, sizeof(struct listData
), ENTRY(listDispatcher
))) != NULL
)
567 /**************************************************************************/
569 static void disposeListClass(void)
571 if(listClass
!= NULL
)
572 MUI_DeleteCustomClass(listClass
);
575 /**************************************************************************/
591 struct IClass
*editClass
;
598 /**************************************************************************/
600 static IPTR
mNew(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
602 Object
*appl
, *addb
, *editb
, *cloneb
, *deleteb
, *disableb
, *upb
, *downb
;
603 struct IClass
*editWinClass
;
605 CONST_STRPTR helpNode
;
606 ULONG nameOfs
, pathOfs
, nodeSize
, editWinAttr
, listAttr
, help
, id
;
609 switch (GetTagData(MUIA_AppList_Type
,0,msg
->ops_AttrList
))
611 case MUIV_AppList_Type_Browser
:
612 nameOfs
= sizeof(struct MinNode
) + sizeof(ULONG
);
613 pathOfs
= sizeof(struct MinNode
) + sizeof(ULONG
) + NAME_LEN
;
614 nodeSize
= sizeof(struct URL_BrowserNode
);
615 editWinClass
= g_browserEditWinClass
->mcc_Class
;
616 editWinAttr
= MUIA_BrowserEditWin_Browser
;
617 listAttr
= MUIA_BrowserEditWin_ListObj
;
618 nodeName
= getString(MSG_Browser_NewBrowser
);
619 helpNode
= "BROWSER";
620 help
= MSG_Browser_List_Help
;
621 id
= MAKE_ID('B','L','S','T');
624 case MUIV_AppList_Type_Mailer
:
625 nameOfs
= sizeof(struct MinNode
) + sizeof(ULONG
);
626 pathOfs
= sizeof(struct MinNode
) + sizeof(ULONG
) + NAME_LEN
;
627 nodeSize
= sizeof(struct URL_MailerNode
);
628 editWinClass
= g_mailerEditWinClass
->mcc_Class
;
629 editWinAttr
= MUIA_MailerEditWin_Mailer
;
630 listAttr
= MUIA_MailerEditWin_ListObj
;
631 nodeName
= getString(MSG_Mailer_NewMailer
);
632 helpNode
= "MAILERS";
633 help
= MSG_Mailer_List_Help
;
634 id
= MAKE_ID('M','L','S','T');
637 case MUIV_AppList_Type_FTP
:
638 nameOfs
= sizeof(struct MinNode
) + sizeof(ULONG
);
639 pathOfs
= sizeof(struct MinNode
) + sizeof(ULONG
) + NAME_LEN
;
640 nodeSize
= sizeof(struct URL_FTPNode
);
641 editWinClass
= g_FTPEditWinClass
->mcc_Class
;
642 editWinAttr
= MUIA_FTPEditWin_FTP
;
643 listAttr
= MUIA_FTPEditWin_ListObj
;
644 nodeName
= getString(MSG_FTP_NewFTP
);
646 help
= MSG_FTP_List_Help
;
647 id
= MAKE_ID('F','L','S','T');
654 if((obj
= (Object
*)DoSuperNew(cl
,obj
,
655 MUIA_HelpNode
, helpNode
,
656 MUIA_ShortHelp
, getString(help
),
657 MUIA_Group_Horiz
, TRUE
,
658 MUIA_Group_HorizSpacing
, 2,
660 Child
, ListviewObject
,
661 MUIA_CycleChain
, TRUE
,
662 MUIA_Listview_DefClickColumn
, 1,
663 MUIA_Listview_DragType
, MUIV_Listview_DragType_Immediate
,
664 MUIA_Listview_List
, appl
= listObject
,
666 MUIA_AppList_NodeNameOffset
, nameOfs
,
667 MUIA_AppList_NodePathOffset
, pathOfs
,
668 MUIA_AppList_NodeSize
, nodeSize
,
674 //MUIA_Background, MUII_GroupBack,
675 MUIA_Group_VertSpacing
, 2,
678 Child
, addb
= obutton(MSG_AppList_Add
,MSG_AppList_Add_Help
),
679 Child
, editb
= obutton(MSG_AppList_Edit
,MSG_AppList_Edit_Help
),
680 Child
, cloneb
= obutton(MSG_AppList_Clone
,MSG_AppList_Clone_Help
),
681 Child
, deleteb
= obutton(MSG_AppList_Delete
,MSG_AppList_Delete_Help
),
683 MUIA_Group_HorizSpacing
, 1,
684 Child
, upb
= oibutton(IBT_Up
,MSG_AppList_MoveUp_Help
),
685 Child
, downb
= oibutton(IBT_Down
,MSG_AppList_MoveDown_Help
),
686 Child
, disableb
= otbutton(MSG_AppList_Disable
,MSG_AppList_Disable_Help
),
691 TAG_MORE
, msg
->ops_AttrList
)) != NULL
)
693 struct data
*data
= INST_DATA(cl
,obj
);
695 /* init instance data */
696 data
->appList
= appl
;
699 data
->clone
= cloneb
;
700 data
->delete = deleteb
;
701 data
->disable
= disableb
;
705 data
->nameOfs
= nameOfs
;
706 data
->pathOfs
= pathOfs
;
707 data
->nodeSize
= nodeSize
;
709 data
->editClass
= editWinClass
;
710 data
->editAttr
= editWinAttr
;
711 data
->listAttr
= listAttr
;
712 data
->newNodeName
= nodeName
;
715 DoMethod(appl
,MUIM_Notify
,MUIA_List_Active
,MUIV_EveryTime
,(IPTR
)obj
,1,MUIM_AppList_ActiveChanged
);
716 DoMethod(appl
,MUIM_Notify
,MUIA_Listview_DoubleClick
,MUIV_EveryTime
,(IPTR
)obj
,2,MUIM_AppList_Edit
,TRUE
);
719 DoMethod(obj
,MUIM_MultiSet
,MUIA_Disabled
,TRUE
,
729 DoMethod(addb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(IPTR
)obj
,1,MUIM_AppList_Add
);
730 DoMethod(editb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(IPTR
)obj
,1,MUIM_AppList_Edit
,FALSE
);
731 DoMethod(cloneb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(IPTR
)obj
,1,MUIM_AppList_Clone
);
732 DoMethod(deleteb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(IPTR
)obj
,1,MUIM_AppList_Delete
);
733 DoMethod(disableb
,MUIM_Notify
,MUIA_Selected
,MUIV_EveryTime
,(IPTR
)obj
,2,MUIM_AppList_Disable
,MUIV_TriggerValue
);
734 DoMethod(upb
,MUIM_Notify
,MUIA_Timer
,MUIV_EveryTime
,(IPTR
)obj
,2,MUIM_AppList_Move
,TRUE
);
735 DoMethod(downb
,MUIM_Notify
,MUIA_Timer
,MUIV_EveryTime
,(IPTR
)obj
,2,MUIM_AppList_Move
,FALSE
);
741 /**************************************************************************/
743 ** I hate this: it will be removed asap!
746 static IPTR
mGet(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
748 struct data
*data
= INST_DATA(cl
,obj
);
750 switch (msg
->opg_AttrID
)
752 case MUIA_AppList_ListObj
: *msg
->opg_Storage
= (IPTR
)data
->appList
; return TRUE
;
753 default: return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
757 /**************************************************************************/
759 static IPTR
mAdd(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
761 struct data
*data
= INST_DATA(cl
,obj
);
762 struct URL_Node
*node
;
764 if (!(node
= AllocPooled(g_pool
,data
->nodeSize
))) return FALSE
;
766 memset(node
,0,data
->nodeSize
);
767 strcpy((STRPTR
)node
+data
->nameOfs
,data
->newNodeName
);
769 node
->Flags
= UNF_NEW
|UNF_NTALLOC
;
771 DoMethod(data
->appList
,MUIM_List_InsertSingle
,(IPTR
)node
,MUIV_List_Insert_Bottom
);
773 set(data
->appList
,MUIA_List_Active
,xget(data
->appList
,MUIA_List_InsertPosition
));
775 DoMethod(obj
,MUIM_AppList_Edit
,FALSE
);
780 /**************************************************************************/
782 static IPTR
mEdit(struct IClass
*cl
, Object
*obj
, struct MUIP_AppList_Edit
*msg
)
784 struct data
*data
= INST_DATA(cl
,obj
);
785 struct URL_Node
*node
;
787 DoMethod(data
->appList
,MUIM_List_GetEntry
,MUIV_List_GetEntry_Active
,(IPTR
)&node
);
790 if (msg
->check
&& (xget(data
->appList
,MUIA_Listview_ClickColumn
)==0))
792 set(data
->appList
,MUIA_Listview_ClickColumn
,1);
794 if(isFlagSet(node
->Flags
, UNF_DISABLED
))
795 CLEAR_FLAG(node
->Flags
, UNF_DISABLED
);
797 SET_FLAG(node
->Flags
, UNF_DISABLED
);
799 DoMethod(data
->appList
, MUIM_List_Redraw
, xget(data
->appList
, MUIA_List_Active
));
800 set(data
->disable
, MUIA_Selected
, isFlagSet(node
->Flags
, UNF_DISABLED
));
803 DoMethod(_app(obj
),MUIM_App_OpenWin
,(IPTR
)data
->editClass
,data
->editAttr
,(IPTR
)node
,data
->listAttr
,(IPTR
)data
->appList
,TAG_END
);
809 /**************************************************************************/
811 static IPTR
mClone(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
813 ULONG success
= FALSE
;
814 struct data
*data
= INST_DATA(cl
,obj
);
815 struct URL_Node
*node
;
818 active
= xget(data
->appList
, MUIA_List_Active
);
819 DoMethod(data
->appList
, MUIM_List_GetEntry
, active
, (IPTR
)&node
);
822 struct URL_Node
*new;
824 if((new = AllocPooled(g_pool
, data
->nodeSize
)) != NULL
)
826 CopyMem(node
, new, data
->nodeSize
);
827 new->Flags
= UNF_NEW
|UNF_NTALLOC
;
829 DoMethod(data
->appList
, MUIM_List_InsertSingle
, (IPTR
)new, MUIV_List_Insert_Bottom
);
830 set(data
->appList
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
832 DoMethod(obj
, MUIM_AppList_Edit
, FALSE
);
841 /**************************************************************************/
843 static IPTR
mDelete(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
845 struct data
*data
= INST_DATA(cl
,obj
);
849 active
= xget(data
->appList
,MUIA_List_Active
);
850 DoMethod(data
->appList
,MUIM_List_GetEntry
,active
,(IPTR
)&node
);
853 DoMethod(_app(obj
),MUIM_App_CloseWin
,data
->editAttr
,(IPTR
)node
);
854 DoMethod(data
->appList
,MUIM_List_Remove
,active
);
860 /**************************************************************************/
862 static IPTR
mActiveChanged(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
864 struct data
*data
= INST_DATA(cl
,obj
);
867 a
= (LONG
)xget(data
->appList
,MUIA_List_Active
);
870 struct URL_Node
*node
;
873 DoMethod(obj
,MUIM_MultiSet
,MUIA_Disabled
,FALSE
,
880 DoMethod(data
->appList
,MUIM_List_GetEntry
,a
,(IPTR
)&node
);
881 set(data
->disable
, MUIA_Selected
, isFlagSet(node
->Flags
, UNF_DISABLED
));
883 if (a
==0) SetAttrs(data
->up
,MUIA_Selected
,FALSE
,MUIA_Disabled
,TRUE
,TAG_DONE
);
884 else set(data
->up
,MUIA_Disabled
,FALSE
);
886 n
= xget(data
->appList
,MUIA_List_Entries
);
887 if (n
-1<=a
) SetAttrs(data
->down
,MUIA_Selected
,FALSE
,MUIA_Disabled
,TRUE
,TAG_DONE
);
888 else set(data
->down
,MUIA_Disabled
,FALSE
);
892 set(data
->disable
,MUIA_Selected
,FALSE
);
894 DoMethod(obj
,MUIM_MultiSet
,MUIA_Disabled
,TRUE
,
907 /**************************************************************************/
909 static IPTR
mDisable(struct IClass
*cl
, Object
*obj
, struct MUIP_AppList_Disable
*msg
)
911 struct data
*data
= INST_DATA(cl
,obj
);
912 struct URL_Node
*node
;
914 DoMethod(data
->appList
,MUIM_List_GetEntry
,MUIV_List_GetEntry_Active
,(IPTR
)&node
);
917 if (!BOOLSAME(msg
->disable
, isFlagSet(node
->Flags
, UNF_DISABLED
)))
920 SET_FLAG(node
->Flags
, UNF_DISABLED
);
922 CLEAR_FLAG(node
->Flags
, UNF_DISABLED
);
924 DoMethod(data
->appList
,MUIM_List_Redraw
,xget(data
->appList
,MUIA_List_Active
));
931 /**************************************************************************/
933 static IPTR
mMove(struct IClass
*cl
, Object
*obj
, struct MUIP_AppList_Move
*msg
)
935 struct data
*data
= INST_DATA(cl
,obj
);
937 DoMethod(data
->appList
,MUIM_List_Exchange
,MUIV_List_Exchange_Active
,msg
->up
? MUIV_List_Exchange_Previous
: MUIV_List_Exchange_Next
);
938 set(data
->appList
,MUIA_List_Active
,msg
->up
? MUIV_List_Active_Up
: MUIV_List_Active_Down
);
943 /**************************************************************************/
945 ** Forward to the list
948 static IPTR
mCheckSave(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
950 struct data
*data
= INST_DATA(cl
,obj
);
952 return DoMethod(data
->appList
,MUIM_App_CheckSave
);
955 /**************************************************************************/
957 SDISPATCHER(dispatcher
)
959 switch (msg
->MethodID
)
961 case OM_NEW
: return mNew(cl
,obj
,(APTR
)msg
);
962 case OM_GET
: return mGet(cl
,obj
,(APTR
)msg
);
964 case MUIM_AppList_Add
: return mAdd(cl
,obj
,(APTR
)msg
);
965 case MUIM_AppList_Edit
: return mEdit(cl
,obj
,(APTR
)msg
);
966 case MUIM_AppList_Clone
: return mClone(cl
,obj
,(APTR
)msg
);
967 case MUIM_AppList_Delete
: return mDelete(cl
,obj
,(APTR
)msg
);
968 case MUIM_AppList_ActiveChanged
: return mActiveChanged(cl
,obj
,(APTR
)msg
);
969 case MUIM_AppList_Disable
: return mDisable(cl
,obj
,(APTR
)msg
);
970 case MUIM_AppList_Move
: return mMove(cl
,obj
,(APTR
)msg
);
971 case MUIM_App_CheckSave
: return mCheckSave(cl
,obj
,(APTR
)msg
);
973 default: return DoSuperMethodA(cl
,obj
,msg
);
977 /**************************************************************************/
979 BOOL
initAppListClass(void)
981 BOOL success
= FALSE
;
985 if(initListClass() == TRUE
)
987 if((g_appListClass
= MUI_CreateCustomClass(NULL
, MUIC_Group
, NULL
, sizeof(struct data
), ENTRY(dispatcher
))) != NULL
)
1000 /**************************************************************************/
1002 void disposeAppListClass(void)
1008 if(g_appListClass
!= NULL
)
1009 MUI_DeleteCustomClass(g_appListClass
);
1014 /**************************************************************************/