2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
11 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
17 #define CATCOMP_NUMBERS
19 #include "libraries/openurl.h"
21 /**************************************************************************/
23 ** Little lamp class for enabled/disabled
26 static struct MUI_CustomClass
*lampClass
= NULL
;
28 #define lampObject BOOPSIOBJMACRO_START(lampClass->mcc_Class)
30 #define lampObject NewObject(lampClass->mcc_Class,NULL
35 struct MUI_PenSpec
**specs
; /* We don't need to save them, because of Pens window is always valid */
48 FLG_LampDisabled
= 1<<1,
51 /***********************************************************************/
54 mLampNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
56 return (ULONG
)DoSuperNew(cl
,obj
,
57 MUIA_Font
, MUIV_Font_List
,
58 TAG_MORE
, msg
->ops_AttrList
);
61 /**************************************************************************/
64 mLampSets(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
66 struct lampData
*data
= INST_DATA(cl
,obj
);
69 if (tag
= FindTagItem(MUIA_Lamp_Disabled
,msg
->ops_AttrList
))
71 if (tag
->ti_Data
) data
->flags
|= FLG_LampDisabled
;
72 else data
->flags
&= ~FLG_LampDisabled
;
74 /* Of course, we don't redraw here */
77 if (tag
= FindTagItem(MUIA_App_Pens
,msg
->ops_AttrList
))
79 struct MUI_PenSpec
**specs
= (struct MUI_PenSpec
**)tag
->ti_Data
;
83 if (data
->flags
& FLG_LampSetup
)
85 MUI_ReleasePen(muiRenderInfo(obj
),data
->enabled
);
86 MUI_ReleasePen(muiRenderInfo(obj
),data
->disabled
);
87 MUI_ReleasePen(muiRenderInfo(obj
),data
->detail
);
88 data
->enabled
= MUI_ObtainPen(muiRenderInfo(obj
),specs
[0],0);
89 data
->disabled
= MUI_ObtainPen(muiRenderInfo(obj
),specs
[1],0);
90 data
->detail
= MUI_ObtainPen(muiRenderInfo(obj
),specs
[2],0);
92 /* Of course, we don't redraw here */
93 data
->flags
|= FLG_LampSetup
;
97 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
100 /***********************************************************************/
103 mLampSetup(struct IClass
*cl
,Object
*obj
,struct MUIP_Setup
*msg
)
105 struct lampData
*data
= INST_DATA(cl
,obj
);
106 if (!DoSuperMethodA(cl
,obj
,(APTR
)msg
)) return FALSE
;
107 data
->enabled
= MUI_ObtainPen(muiRenderInfo(obj
),data
->specs
[0],0);
108 data
->disabled
= MUI_ObtainPen(muiRenderInfo(obj
),data
->specs
[1],0);
109 data
->detail
= MUI_ObtainPen(muiRenderInfo(obj
),data
->specs
[2],0);
111 data
->flags
|= FLG_LampSetup
;
116 /***********************************************************************/
119 mLampCleanup(struct IClass
*cl
,Object
*obj
,struct MUIP_Setup
*msg
)
121 struct lampData
*data
= INST_DATA(cl
,obj
);
123 if (data
->flags
& FLG_LampSetup
)
125 MUI_ReleasePen(muiRenderInfo(obj
),data
->enabled
);
126 MUI_ReleasePen(muiRenderInfo(obj
),data
->disabled
);
127 MUI_ReleasePen(muiRenderInfo(obj
),data
->detail
);
129 data
->flags
&= ~FLG_LampSetup
;
132 return DoSuperMethodA(cl
,obj
,(APTR
)msg
);
135 /***********************************************************************/
138 mLampAskMinMax(struct IClass
*cl
,Object
*obj
,struct MUIP_AskMinMax
*msg
)
140 struct lampData
*data
= INST_DATA(cl
,obj
);
142 struct TextExtent te
;
145 DoSuperMethodA(cl
,obj
,(APTR
)msg
);
147 CopyMem(&_screen(obj
)->RastPort
,&rp
,sizeof(rp
));
149 /* Don't ask or modify ! */
151 SetFont(&rp
,_font(obj
));
152 TextExtent(&rp
," ",2,&te
);
160 data
->delta
= te
.te_Extent
.MinY
;
162 msg
->MinMaxInfo
->MinWidth
+= d
;
163 msg
->MinMaxInfo
->MinHeight
+= h
;
164 msg
->MinMaxInfo
->DefWidth
+= d
;
165 msg
->MinMaxInfo
->DefHeight
+= h
;
166 msg
->MinMaxInfo
->MaxWidth
+= d
;
167 msg
->MinMaxInfo
->MaxHeight
+= h
;
172 /***********************************************************************/
175 mLampDraw(struct IClass
*cl
,Object
*obj
,struct MUIP_Draw
*msg
)
177 struct lampData
*data
= INST_DATA(cl
,obj
);
180 res
= DoSuperMethodA(cl
,obj
,(APTR
)msg
);
182 if (msg
->flags
& (MADF_DRAWOBJECT
|MADF_DRAWUPDATE
))
186 /* Don't ask or modify ! */
190 t
= _mtop(obj
)+(_mheight(obj
)+data
->delta
)/2-1;
205 SetAPen(_rp(obj
),MUIPEN((data
->flags
& FLG_LampDisabled
) ? data
->disabled
: data
->enabled
));
206 RectFill(_rp(obj
),l
,t
,r
,b
);
208 SetAPen(_rp(obj
),MUIPEN(data
->detail
));
219 /***********************************************************************/
221 M_DISP(lampDispatcher
)
225 switch(msg
->MethodID
)
227 case OM_NEW
: return mLampNew(cl
,obj
,(APTR
)msg
);
228 case OM_SET
: return mLampSets(cl
,obj
,(APTR
)msg
);
230 case MUIM_Setup
: return mLampSetup(cl
,obj
,(APTR
)msg
);
231 case MUIM_Cleanup
: return mLampCleanup(cl
,obj
,(APTR
)msg
);
232 case MUIM_AskMinMax
: return mLampAskMinMax(cl
,obj
,(APTR
)msg
);
233 case MUIM_Draw
: return mLampDraw(cl
,obj
,(APTR
)msg
);
235 default: return DoSuperMethodA(cl
,obj
,msg
);
239 M_DISPEND(lampDispatcher
)
241 /***********************************************************************/
246 return (ULONG
)(lampClass
= MUI_CreateCustomClass(NULL
,MUIC_Rectangle
,NULL
,sizeof(struct lampData
),DISP(lampDispatcher
)));
249 /**************************************************************************/
252 disposeLampClass(void)
254 if (lampClass
) MUI_DeleteCustomClass(lampClass
);
257 /**************************************************************************/
259 ** List of clients with lamps
262 static struct MUI_CustomClass
*listClass
= NULL
;
264 #define listObject BOOPSIOBJMACRO_START(listClass->mcc_Class)
266 #define listObject NewObject(listClass->mcc_Class,NULL
273 TEXT col0buf
[NAME_LEN
+16];
286 FLG_ListSetup
= 1<<0,
289 /* Used for Import/Export */
296 /**************************************************************************/
299 static struct URL_Node
*
302 struct Hook
*hook
= (struct Hook
*)REG_a0
;
303 APTR pool
= (APTR
)REG_A2
;
304 struct URL_Node
*node
= (struct URL_Node
*)REG_A1
;
305 #elif defined(__AROS__)
306 AROS_UFH3S(struct URL_Node
*, conFun
,
307 AROS_UFHA(struct Hook
* , hook
, A0
),
308 AROS_UFHA(APTR
, pool
, A2
),
309 AROS_UFHA(struct URL_Node
*, node
, A1
))
313 static struct URL_Node
* SAVEDS ASM
314 conFun(REG(a0
,struct Hook
*hook
),REG(a2
,APTR pool
),REG(a1
,struct URL_Node
*node
))
317 struct listData
*data
= hook
->h_Data
;
318 struct URL_Node
*new;
320 if (node
->Flags
& UNF_NTALLOC
)
323 node
->Flags
&= ~UNF_NTALLOC
;
325 else if (new = AllocPooled(pool
,data
->nodeSize
)) CopyMem(node
,new,data
->nodeSize
);
334 static struct EmulLibEntry conTrap
= {TRAP_LIB
,0,(void (*)(void))conFun
};
335 static struct Hook conHook
= {0,0,(HOOKFUNC
)&conTrap
};
337 static struct Hook conHook
= {0,0,(HOOKFUNC
)conFun
};
340 /**************************************************************************/
346 struct Hook
*hook
= (struct Hook
*)REG_a0
;
347 APTR pool
= (APTR
)REG_A2
;
348 struct URL_Node
*node
= (struct URL_Node
*)REG_A1
;
349 #elif defined(__AROS__)
350 AROS_UFH3S(void, destFun
,
351 AROS_UFHA(struct Hook
* , hook
, A0
),
352 AROS_UFHA(APTR
, pool
, A2
),
353 AROS_UFHA(struct URL_Node
*, node
, A1
))
357 static void SAVEDS ASM
358 destFun(REG(a0
,struct Hook
*hook
),REG(a2
,APTR pool
),REG(a1
,struct URL_Node
*node
))
361 struct listData
*data
= hook
->h_Data
;
363 FreePooled(pool
,node
,data
->nodeSize
);
370 static struct EmulLibEntry destTrap
= {TRAP_LIBNR
,0,(void (*)(void))destFun
};
371 static struct Hook destHook
= {0,0,(HOOKFUNC
)&destTrap
};
373 static struct Hook destHook
= {0,0,(HOOKFUNC
)destFun
};
376 /**************************************************************************/
382 struct Hook
*hook
= (struct Hook
*)REG_a0
;
383 STRPTR
*array
= (STRPTR
*)REG_A2
;
384 struct URL_Node
*node
= (struct URL_Node
*)REG_A1
;
385 #elif defined(__AROS__)
386 AROS_UFH3S(void, dispFun
,
387 AROS_UFHA(struct Hook
* , hook
, A0
),
388 AROS_UFHA(STRPTR
* , array
, A2
),
389 AROS_UFHA(struct URL_Node
*, node
, A1
))
393 static void SAVEDS ASM
394 dispFun(REG(a0
,struct Hook
*hook
),REG(a2
,STRPTR
*array
),REG(a1
,struct URL_Node
*node
))
397 struct listData
*data
= hook
->h_Data
;
401 if (data
->lamp
&& data
->olamp
)
403 set(data
->olamp
,MUIA_Lamp_Disabled
,node
->Flags
& UNF_DISABLED
);
404 //msprintf(data->col0buf,"\33O[%08lx] %s",(ULONG)data->lamp,(ULONG)((UBYTE *)node+data->nameOfs));
405 msprintf(data
->col0buf
,"\33O[%08lx]",(ULONG
)data
->lamp
);
406 *array
++ = data
->col0buf
;
410 //msprintf(data->col0buf,"%s %s",(ULONG)((node->Flags & UNF_DISABLED) ? " " : ">"),(ULONG)
412 *array
++ = (STRPTR
)node
+data
->nameOfs
;
413 *array
= (STRPTR
)node
+data
->pathOfs
;
418 *array
++ = getString(MSG_Edit_ListName
);
419 *array
= getString(MSG_Edit_ListPath
);
427 static struct EmulLibEntry dispTrap
= {TRAP_LIBNR
,0,(void (*)(void))dispFun
};
428 static struct Hook dispHook
= {0,0,(HOOKFUNC
)&dispTrap
};
430 static struct Hook dispHook
= {0,0,(HOOKFUNC
)dispFun
};
433 /**************************************************************************/
436 mListNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
438 if (obj
= (Object
*)DoSuperNew(cl
,obj
,
440 MUIA_List_Title
, TRUE
,
441 MUIA_List_Format
, "C=0,C=1,C=2",
442 MUIA_List_DragSortable
, TRUE
,
443 MUIA_List_Pool
, g_pool
,
444 MUIA_List_ConstructHook
, &conHook
,
445 MUIA_List_DestructHook
, &destHook
,
446 MUIA_List_DisplayHook
, &dispHook
,
447 MUIA_List_DragSortable
, TRUE
,
448 MUIA_List_ShowDropMarks
, TRUE
,
449 0x8042bc08, 1, /* MUI4 Auto Line Height: put the real name if you know it :P */
450 TAG_MORE
, msg
->ops_AttrList
))
452 struct listData
*data
= INST_DATA(cl
,obj
);
454 data
->nameOfs
= GetTagData(MUIA_AppList_NodeNameOffset
,0,msg
->ops_AttrList
);
455 data
->pathOfs
= GetTagData(MUIA_AppList_NodePathOffset
,0,msg
->ops_AttrList
);
456 data
->nodeSize
= GetTagData(MUIA_AppList_NodeSize
,0,msg
->ops_AttrList
);
458 strcpy(data
->format
,"C=0,C=1,C=2");
460 if (lampClass
) data
->olamp
= lampObject
, End
;
462 conHook
.h_Data
= data
;
463 destHook
.h_Data
= data
;
464 dispHook
.h_Data
= data
;
470 /**************************************************************************/
473 mListDispose(struct IClass
*cl
,Object
*obj
,Msg msg
)
475 struct listData
*data
= INST_DATA(cl
,obj
);
477 if (data
->olamp
) MUI_DisposeObject(data
->olamp
);
479 return DoSuperMethodA(cl
,obj
,msg
);
482 /**************************************************************************/
485 mListSets(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
489 if (tag
= FindTagItem(MUIA_App_Pens
,msg
->ops_AttrList
))
491 struct listData
*data
= INST_DATA(cl
,obj
);
494 struct MUI_PenSpec
**specs
= (struct MUI_PenSpec
**)tag
->ti_Data
;
495 set(data
->olamp
,MUIA_App_Pens
,specs
);
496 tag
->ti_Tag
= TAG_IGNORE
;
498 /* Don't want even know why a push is needed here! */
499 if (data
->flags
& FLG_ListSetup
)
500 DoMethod(_app(obj
),MUIM_Application_PushMethod
,(ULONG
)obj
,2,MUIM_List_Redraw
,MUIV_List_Redraw_All
);
504 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
507 /***********************************************************************/
510 mListSetup(struct IClass
*cl
,Object
*obj
,struct MUIP_Setup
*msg
)
512 struct listData
*data
= INST_DATA(cl
,obj
);
514 if (!DoSuperMethodA(cl
,obj
,(APTR
)msg
)) return FALSE
;
516 /* After thinking about that hard, I decided to use the lamp in >=8 color screen */
517 if (data
->olamp
&& (GetBitMapAttr(_screen(obj
)->RastPort
.BitMap
,BMA_DEPTH
)>3))
518 data
->lamp
= (APTR
)DoSuperMethod(cl
,obj
,MUIM_List_CreateImage
,(ULONG
)data
->olamp
,0);
520 data
->flags
|= FLG_ListSetup
;
525 /***********************************************************************/
528 mListCleanup(struct IClass
*cl
,Object
*obj
,struct MUIP_Setup
*msg
)
530 struct listData
*data
= INST_DATA(cl
,obj
);
532 if (data
->flags
& FLG_ListSetup
)
536 DoSuperMethod(cl
,obj
,MUIM_List_DeleteImage
,(ULONG
)data
->lamp
);
540 data
->flags
&= ~FLG_ListSetup
;
543 return DoSuperMethodA(cl
,obj
,(APTR
)msg
);
546 /***********************************************************************/
552 mListImport(struct IClass
*cl
,Object
*obj
,struct MUIP_Import
*msg
)
556 if (id
= (muiNotifyData(obj
)->mnd_ObjectID
))
558 register struct listIO
*io
;
560 if (io
= (struct listIO
*)DoMethod(msg
->dataspace
,MUIM_Dataspace_Find
,id
))
562 struct listData
*data
= INST_DATA(cl
,obj
);
564 stccpy(data
->format
,io
->format
,sizeof(data
->format
));
565 set(obj
,MUIA_List_Format
,data
->format
);
572 /***********************************************************************/
578 mListExport(struct IClass
*cl
,Object
*obj
,struct MUIP_Import
*msg
)
582 if (id
= (muiNotifyData(obj
)->mnd_ObjectID
))
587 get(obj
,MUIA_List_Format
,&f
);
588 io
.len
= strlen(f
)+1;
589 stccpy(io
.format
,f
,sizeof(io
.format
));
591 DoMethod(msg
->dataspace
,MUIM_Dataspace_Add
,(ULONG
)&io
,sizeof(ULONG
)+io
.len
,id
);
597 /**************************************************************************/
599 ** Check if format changed
603 mListCheckSave(struct IClass
*cl
,Object
*obj
,Msg msg
)
605 struct listData
*data
= INST_DATA(cl
,obj
);
607 // Zune doesn't have MUIA_List_Format
612 get(obj
,MUIA_List_Format
,&f
);
614 return (ULONG
)strcmp((STRPTR
)f
,(STRPTR
)&data
->format
);
618 /**************************************************************************/
620 M_DISP(listDispatcher
)
624 switch (msg
->MethodID
)
626 case OM_NEW
: return mListNew(cl
,obj
,(APTR
)msg
);
627 case OM_DISPOSE
: return mListDispose(cl
,obj
,(APTR
)msg
);
628 case OM_SET
: return mListSets(cl
,obj
,(APTR
)msg
);
630 case MUIM_Setup
: return mListSetup(cl
,obj
,(APTR
)msg
);
631 case MUIM_Cleanup
: return mListCleanup(cl
,obj
,(APTR
)msg
);
632 case MUIM_Import
: return mListImport(cl
,obj
,(APTR
)msg
);
633 case MUIM_Export
: return mListExport(cl
,obj
,(APTR
)msg
);
635 case MUIM_App_CheckSave
: return mListCheckSave(cl
,obj
,(APTR
)msg
);
637 default: return DoSuperMethodA(cl
,obj
,msg
);
641 M_DISPEND(listDispatcher
)
643 /**************************************************************************/
648 return (ULONG
)(listClass
= MUI_CreateCustomClass(NULL
,MUIC_List
,NULL
,sizeof(struct listData
),DISP(listDispatcher
)));
651 /**************************************************************************/
654 disposeListClass(void)
656 if (listClass
) MUI_DeleteCustomClass(listClass
);
659 /**************************************************************************/
675 struct IClass
*editClass
;
682 /**************************************************************************/
685 mNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
687 Object
*appl
, *addb
, *editb
, *cloneb
, *deleteb
, *disableb
, *upb
, *downb
;
688 struct IClass
*editWinClass
;
689 STRPTR nodeName
, helpNode
;
690 ULONG nameOfs
, pathOfs
, nodeSize
, editWinAttr
, listAttr
, help
, id
;
693 switch (GetTagData(MUIA_AppList_Type
,0,msg
->ops_AttrList
))
695 case MUIV_AppList_Type_Browser
:
696 nameOfs
= sizeof(struct MinNode
) + sizeof(ULONG
);
697 pathOfs
= sizeof(struct MinNode
) + sizeof(ULONG
) + NAME_LEN
;
698 nodeSize
= sizeof(struct URL_BrowserNode
);
699 editWinClass
= g_browserEditWinClass
->mcc_Class
;
700 editWinAttr
= MUIA_BrowserEditWin_Browser
;
701 listAttr
= MUIA_BrowserEditWin_ListObj
;
702 nodeName
= getString(MSG_Browser_NewBrowser
);
703 helpNode
= "BROWSER";
704 help
= MSG_Browser_List_Help
;
705 id
= MAKE_ID('B','L','S','T');
708 case MUIV_AppList_Type_Mailer
:
709 nameOfs
= sizeof(struct MinNode
) + sizeof(ULONG
);
710 pathOfs
= sizeof(struct MinNode
) + sizeof(ULONG
) + NAME_LEN
;
711 nodeSize
= sizeof(struct URL_MailerNode
);
712 editWinClass
= g_mailerEditWinClass
->mcc_Class
;
713 editWinAttr
= MUIA_MailerEditWin_Mailer
;
714 listAttr
= MUIA_MailerEditWin_ListObj
;
715 nodeName
= getString(MSG_Mailer_NewMailer
);
716 helpNode
= "MAILERS";
717 help
= MSG_Mailer_List_Help
;
718 id
= MAKE_ID('M','L','S','T');
721 case MUIV_AppList_Type_FTP
:
722 nameOfs
= sizeof(struct MinNode
) + sizeof(ULONG
);
723 pathOfs
= sizeof(struct MinNode
) + sizeof(ULONG
) + NAME_LEN
;
724 nodeSize
= sizeof(struct URL_FTPNode
);
725 editWinClass
= g_FTPEditWinClass
->mcc_Class
;
726 editWinAttr
= MUIA_FTPEditWin_FTP
;
727 listAttr
= MUIA_FTPEditWin_ListObj
;
728 nodeName
= getString(MSG_FTP_NewFTP
);
730 help
= MSG_FTP_List_Help
;
731 id
= MAKE_ID('F','L','S','T');
738 if (obj
= (Object
*)DoSuperNew(cl
,obj
,
739 MUIA_HelpNode
, helpNode
,
740 MUIA_ShortHelp
, getString(help
),
741 MUIA_Group_Horiz
, TRUE
,
742 MUIA_Group_HorizSpacing
, 2,
744 Child
, ListviewObject
,
745 MUIA_CycleChain
, TRUE
,
746 MUIA_Listview_DefClickColumn
, 1,
747 MUIA_Listview_DragType
, MUIV_Listview_DragType_Immediate
,
748 MUIA_Listview_List
, appl
= listObject
,
750 MUIA_AppList_NodeNameOffset
, nameOfs
,
751 MUIA_AppList_NodePathOffset
, pathOfs
,
752 MUIA_AppList_NodeSize
, nodeSize
,
758 MUIA_Background
, MUII_GroupBack
,
761 Child
, addb
= obutton(MSG_AppList_Add
,MSG_AppList_Add_Help
),
762 Child
, editb
= obutton(MSG_AppList_Edit
,MSG_AppList_Edit_Help
),
763 Child
, cloneb
= obutton(MSG_AppList_Clone
,MSG_AppList_Clone_Help
),
765 MUIA_Group_HorizSpacing
, 1,
766 Child
, upb
= oibutton(IBT_Up
,MSG_AppList_MoveUp_Help
),
767 Child
, downb
= oibutton(IBT_Down
,MSG_AppList_MoveDown_Help
),
768 Child
, disableb
= otbutton(MSG_AppList_Disable
,MSG_AppList_Disable_Help
),
771 Child
, deleteb
= obutton(MSG_AppList_Delete
,MSG_AppList_Delete_Help
),
774 TAG_MORE
, msg
->ops_AttrList
))
776 struct data
*data
= INST_DATA(cl
,obj
);
778 /* init instance data */
779 data
->appList
= appl
;
782 data
->clone
= cloneb
;
783 data
->delete = deleteb
;
784 data
->disable
= disableb
;
788 data
->nameOfs
= nameOfs
;
789 data
->pathOfs
= pathOfs
;
790 data
->nodeSize
= nodeSize
;
792 data
->editClass
= editWinClass
;
793 data
->editAttr
= editWinAttr
;
794 data
->listAttr
= listAttr
;
795 data
->newNodeName
= nodeName
;
798 DoMethod(appl
,MUIM_Notify
,MUIA_List_Active
,MUIV_EveryTime
,(ULONG
)obj
,1,MUIM_AppList_ActiveChanged
);
799 DoMethod(appl
,MUIM_Notify
,MUIA_Listview_DoubleClick
,MUIV_EveryTime
,(ULONG
)obj
,2,MUIM_AppList_Edit
,TRUE
);
802 DoMethod(obj
,MUIM_MultiSet
,MUIA_Disabled
,TRUE
,
812 DoMethod(addb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(ULONG
)obj
,1,MUIM_AppList_Add
);
813 DoMethod(editb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(ULONG
)obj
,1,MUIM_AppList_Edit
,FALSE
);
814 DoMethod(cloneb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(ULONG
)obj
,1,MUIM_AppList_Clone
);
815 DoMethod(deleteb
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(ULONG
)obj
,1,MUIM_AppList_Delete
);
816 DoMethod(disableb
,MUIM_Notify
,MUIA_Selected
,MUIV_EveryTime
,(ULONG
)obj
,2,MUIM_AppList_Disable
,MUIV_TriggerValue
);
817 DoMethod(upb
,MUIM_Notify
,MUIA_Timer
,MUIV_EveryTime
,(ULONG
)obj
,2,MUIM_AppList_Move
,TRUE
);
818 DoMethod(downb
,MUIM_Notify
,MUIA_Timer
,MUIV_EveryTime
,(ULONG
)obj
,2,MUIM_AppList_Move
,FALSE
);
824 /**************************************************************************/
826 ** I hate this: it will be removed asap!
830 mGet(struct IClass
*cl
,Object
*obj
,struct opGet
*msg
)
832 struct data
*data
= INST_DATA(cl
,obj
);
834 switch (msg
->opg_AttrID
)
836 case MUIA_AppList_ListObj
: *msg
->opg_Storage
= (ULONG
)data
->appList
; return TRUE
;
837 default: return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
841 /**************************************************************************/
844 mAdd(struct IClass
*cl
,Object
*obj
,Msg msg
)
846 struct data
*data
= INST_DATA(cl
,obj
);
847 struct URL_Node
*node
;
849 if (!(node
= AllocPooled(g_pool
,data
->nodeSize
))) return FALSE
;
851 memset(node
,0,data
->nodeSize
);
852 strcpy((STRPTR
)node
+data
->nameOfs
,data
->newNodeName
);
854 node
->Flags
= UNF_NEW
|UNF_NTALLOC
;
856 DoMethod(data
->appList
,MUIM_List_InsertSingle
,(ULONG
)node
,MUIV_List_Insert_Bottom
);
858 set(data
->appList
,MUIA_List_Active
,xget(data
->appList
,MUIA_List_InsertPosition
));
860 DoMethod(obj
,MUIM_AppList_Edit
,FALSE
);
865 /**************************************************************************/
868 mEdit(struct IClass
*cl
,Object
*obj
,struct MUIP_AppList_Edit
*msg
)
870 struct data
*data
= INST_DATA(cl
,obj
);
871 struct URL_Node
*node
;
873 DoMethod(data
->appList
,MUIM_List_GetEntry
,MUIV_List_GetEntry_Active
,(ULONG
)&node
);
876 if (msg
->check
&& (xget(data
->appList
,MUIA_Listview_ClickColumn
)==0))
878 set(data
->appList
,MUIA_Listview_ClickColumn
,1);
880 if (node
->Flags
& UNF_DISABLED
) node
->Flags
&= ~UNF_DISABLED
;
881 else node
->Flags
|= UNF_DISABLED
;
883 DoMethod(data
->appList
,MUIM_List_Redraw
,xget(data
->appList
,MUIA_List_Active
));
884 set(data
->disable
,MUIA_Selected
,node
->Flags
& UNF_DISABLED
);
886 else DoMethod(_app(obj
),MUIM_App_OpenWin
,(ULONG
)data
->editClass
,data
->editAttr
,(ULONG
)node
,data
->listAttr
,(ULONG
)data
->appList
,TAG_END
);
892 /**************************************************************************/
895 mClone(struct IClass
*cl
,Object
*obj
,Msg msg
)
897 struct data
*data
= INST_DATA(cl
,obj
);
898 struct URL_Node
*node
;
901 get(data
->appList
,MUIA_List_Active
,&active
);
902 DoMethod(data
->appList
,MUIM_List_GetEntry
,active
,(ULONG
)&node
);
905 struct URL_Node
*new;
907 if (!(new = AllocPooled(g_pool
,data
->nodeSize
))) return FALSE
;
908 CopyMem(node
,new,data
->nodeSize
);
909 new->Flags
|= UNF_NEW
|UNF_NTALLOC
;
911 DoMethod(data
->appList
,MUIM_List_InsertSingle
,(ULONG
)new,MUIV_List_Insert_Bottom
);
912 set(data
->appList
,MUIA_List_Active
,MUIV_List_Active_Bottom
);
914 DoMethod(obj
,MUIM_AppList_Edit
,FALSE
);
920 /**************************************************************************/
923 mDelete(struct IClass
*cl
,Object
*obj
,Msg msg
)
925 struct data
*data
= INST_DATA(cl
,obj
);
929 get(data
->appList
,MUIA_List_Active
,&active
);
930 DoMethod(data
->appList
,MUIM_List_GetEntry
,active
,(ULONG
)&node
);
933 DoMethod(_app(obj
),MUIM_App_CloseWin
,data
->editAttr
,(ULONG
)node
);
934 DoMethod(data
->appList
,MUIM_List_Remove
,active
);
940 /**************************************************************************/
943 mActiveChanged(struct IClass
*cl
,Object
*obj
,Msg msg
)
945 struct data
*data
= INST_DATA(cl
,obj
);
948 a
= (LONG
)xget(data
->appList
,MUIA_List_Active
);
951 struct URL_Node
*node
;
954 DoMethod(obj
,MUIM_MultiSet
,MUIA_Disabled
,FALSE
,
958 (ULONG
)data
->disable
,
961 DoMethod(data
->appList
,MUIM_List_GetEntry
,a
,(ULONG
)&node
);
962 set(data
->disable
,MUIA_Selected
,node
->Flags
& UNF_DISABLED
);
964 if (a
==0) SetAttrs(data
->up
,MUIA_Selected
,FALSE
,MUIA_Disabled
,TRUE
,TAG_DONE
);
965 else set(data
->up
,MUIA_Disabled
,FALSE
);
967 n
= xget(data
->appList
,MUIA_List_Entries
);
968 if (n
-1<=a
) SetAttrs(data
->down
,MUIA_Selected
,FALSE
,MUIA_Disabled
,TRUE
,TAG_DONE
);
969 else set(data
->down
,MUIA_Disabled
,FALSE
);
973 set(data
->disable
,MUIA_Selected
,FALSE
);
975 DoMethod(obj
,MUIM_MultiSet
,MUIA_Disabled
,TRUE
,
979 (ULONG
)data
->disable
,
988 /**************************************************************************/
991 mDisable(struct IClass
*cl
,Object
*obj
,struct MUIP_AppList_Disable
*msg
)
993 struct data
*data
= INST_DATA(cl
,obj
);
994 struct URL_Node
*node
;
996 DoMethod(data
->appList
,MUIM_List_GetEntry
,MUIV_List_GetEntry_Active
,(ULONG
)&node
);
999 if (!BOOLSAME(msg
->disable
,node
->Flags
& UNF_DISABLED
))
1001 if (msg
->disable
) node
->Flags
|= UNF_DISABLED
;
1002 else node
->Flags
&= ~UNF_DISABLED
;
1004 DoMethod(data
->appList
,MUIM_List_Redraw
,xget(data
->appList
,MUIA_List_Active
));
1011 /**************************************************************************/
1014 mMove(struct IClass
*cl
,Object
*obj
,struct MUIP_AppList_Move
*msg
)
1016 struct data
*data
= INST_DATA(cl
,obj
);
1018 DoMethod(data
->appList
,MUIM_List_Exchange
,MUIV_List_Exchange_Active
,msg
->up
? MUIV_List_Exchange_Previous
: MUIV_List_Exchange_Next
);
1019 set(data
->appList
,MUIA_List_Active
,msg
->up
? MUIV_List_Active_Up
: MUIV_List_Active_Down
);
1024 /**************************************************************************/
1026 ** Forward to the list
1030 mCheckSave(struct IClass
*cl
,Object
*obj
,Msg msg
)
1032 struct data
*data
= INST_DATA(cl
,obj
);
1034 return DoMethod(data
->appList
,MUIM_App_CheckSave
);
1037 /**************************************************************************/
1043 switch (msg
->MethodID
)
1045 case OM_NEW
: return mNew(cl
,obj
,(APTR
)msg
);
1046 case OM_GET
: return mGet(cl
,obj
,(APTR
)msg
);
1048 case MUIM_AppList_Add
: return mAdd(cl
,obj
,(APTR
)msg
);
1049 case MUIM_AppList_Edit
: return mEdit(cl
,obj
,(APTR
)msg
);
1050 case MUIM_AppList_Clone
: return mClone(cl
,obj
,(APTR
)msg
);
1051 case MUIM_AppList_Delete
: return mDelete(cl
,obj
,(APTR
)msg
);
1052 case MUIM_AppList_ActiveChanged
: return mActiveChanged(cl
,obj
,(APTR
)msg
);
1053 case MUIM_AppList_Disable
: return mDisable(cl
,obj
,(APTR
)msg
);
1054 case MUIM_AppList_Move
: return mMove(cl
,obj
,(APTR
)msg
);
1055 case MUIM_App_CheckSave
: return mCheckSave(cl
,obj
,(APTR
)msg
);
1057 default: return DoSuperMethodA(cl
,obj
,msg
);
1061 M_DISPEND(dispatcher
)
1063 /**************************************************************************/
1066 initAppListClass(void)
1068 if (initListClass())
1070 if (g_appListClass
= MUI_CreateCustomClass(NULL
,MUIC_Group
,NULL
,sizeof(struct data
),DISP(dispatcher
)))
1083 /**************************************************************************/
1086 disposeAppListClass(void)
1090 if (g_appListClass
) MUI_DeleteCustomClass(g_appListClass
);
1093 /**************************************************************************/